[英]Unable to get data from new collection on mongodb on node.js using mongoose
I am trying to get data from a (newly created and after renaming the old one) collection using mongoose on mongodb & node.js. 我正在尝试使用mongodb和node.js上的mongoose从一个(新创建的并重命名一个旧的)集合中获取数据。 But the below find method always returns empty list.
但是下面的find方法总是返回空列表。 The same code worked well with the old db and collection.
相同的代码与旧的db和collection配合良好。 Any idea?
任何想法?
module.exports.find = function (schemaName, schema, callback) {
var orm = mongoose.model(schemaName, schema);
orm.find(function(err, data){
if(err) {
looger.error(err);
} else {
callback(data);
}
});
}
明确设置集合名称:
var orm = mongoose.model(schemaName, schema, collectionNewName);
Thanks Umid, that helped too. 感谢Umid,这也有所帮助。 But the actual issue was with naming convesion for the collections.
但是实际的问题在于命名收藏的收藏。 Caps, camel etc naming are not accepted... :(. I don't understand the reason though.
帽,骆驼等命名不被接受... :( ..我不明白原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.