I am new to node.js and mongo db. What I am trying to do is to call the ordered function in my model.js from index.js but I have a complain
object function model() has no method ordered()
routes/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;
};
If you want to add methods to your models, you should use the Mongoose supported ways for doing that. See http://mongoosejs.com/docs/methods-statics.html