mongoose inheritance of statics methods
I had the same issue yesterday, ended up doing something like this:
var Schema = require('mongoose').Schema;function AbstractSchema() { Schema.apply(this, arguments); this.add({ name: String, // ...your fields }); this.statics.removeAll = function(){ this.remove({}).exec(); // ... your functionality };}
Then just create your models;mongoose.model('MyModel', new AbstractSchema())
and MyModel.removeAll();
should work!