According to the documentation I can do such thing:
var animalSchema = new Schema({ name: String, type: String });
animalSchema.methods.findSimilarTypes = function (cb) {
return this.model('Animal').find({ type: this.type }, cb);
}
Suppose I have another function:
animalSchema.methods.owner which filter if animalScheme.owner is xyz, so it modifies the search query to {..., owner: xyz}
Is it possible to use instance sequentially? and how can I achieve this?
var animalSchema.findSimilarTypes().owner("xyz") ?
any hint?
I believe this doesn't work straight away because the original function findSimilarTypes does not return a schema object.
I'm guessing you're trying to do something to how jQuery works.