Hello I need to inherit my schemas in mongoose library. Are there complete plugins for that? Or how should I do that myself?
I need to inherit all pre, post, init mi
Check the models of this framework for Mongoose:
https://github.com/marian2js/rode#models-with-mongoose
This is an example of who to extend shemas with this framework:
First of all define your schema inside a new "rode model":
var rode = require('rode');
var User = rode.Model.extend({
name: 'User',
schema: {
name: {
type: 'String',
unique: true
},
email: String,
password: String
}
});
Now you should call extend method:
var Admin = User.extend({
name: 'Admin',
// The schema for admins is the schema for users + their own schema
schema: {
lastAccess: Date
}
});
But have in mint this note extracted from the framework github: "Both models will share the same collection on MongoDB. Documents of the extended models will have an attribute _type to differentiate."