After checking out the official documentation, I am still not sure on how to create methods for use within mongoose to create & update documents.
So how can I do this?
I have something like this in mind:
mySchema.statics.insertSomething = function insertSomething () {
return this.insert(() ?
}
Methods are used to to interact with the current instance of the model. Example:
Statics are used when you don’t want to interact with an instance, but do model-related stuff (for example search for all Animals named ‘Rover’).
If you want to insert / update an instance of a model (into the db), then
methodsare the way to go. If you just need to save/update stuff you can use thesavefunction (already existent into Mongoose). Example: