Reputation: 15831
I would like to add a static method to the Schema class, how do I do without changing the main Schema class?
thanks
Upvotes: 1
Views: 350
Reputation: 7191
This is how the website documents it:
// assign a function to the "statics" object of our animalSchema
animalSchema.statics.findByName = function (name, cb) {
this.find({ name: new RegExp(name, 'i') }, cb);
}
Upvotes: 1