What is the use of mongoose methods and statics and how are they different from normal functions?
Can anyone explain the difference with example.
If i wanted to retrieve animals with hasTail
i could simply change this line of code:
return this.model('Animal').find({ type: this.type }, cb);
to:
return this.model('Animal').find({ hasTail: true }, cb);
and i would not have to create a statics function.
Use method on individual documents if you want to manipulate the individual document like adding tokens etc. Use the statics approach if you want query the whole collection.