-
Notifications
You must be signed in to change notification settings - Fork 4
Schema plugins
Jean-Baptiste Musso edited this page Oct 28, 2013
·
1 revision
Plugins add a set of methods to existing schemas. They behave pretty much the same in Mogwai as they do in Mongoose.
plugin.js file:
module.exports = function(schema, options) {
schema.method("doSomething", function(callback) {
// ...
});
schema.static("doMoreStuff", function(callback) {
// ...
});
}var mogwai = require("mogwai");
var myplugin = require("./path/to/my/plugin");
UserSchema = new mogwai.Schema(/*...*/)
// Attach plugin to UserSchema
UserSchema.plugin(myplugin);Please note that plugins currently do not support attached .groovy files, but this should change in the future.