0
我是新來的node.js和mongo db。我所試圖做的是調用命令函數從index.js我model.js但我有一個抱怨找不到方法錯誤
目標函數模型()沒有下令方法()
路線/index.js
var pics_ = models.Picture.ordered();
model.js
Picture.prototype.ordered = function() {
var ordered = mongoose.Picture.find().sort({points:-1}).toArray()
console.log(ordered);
return ordered;
};
您是否在model.js中導出圖片對象? –
是的。我是var Picture = mongoose.model('Picture',PictureSchema); exports.Picture = Picture; – LivingThing