README
Mongoose Ref Validator
Validate that referenced documents exist in Mongoose.
Installation
npm install mongoose-ref-validator
Usage
Add plugin to Mongoose.
mongoose.plugin(require('mongoose-ref-validator'));
Enable validation by adding a conditions
property.
var messageSchema = new Schema({
channel: {
conditions: {}, // Enables validation
type: ObjectId,
ref: 'Channel'
},
user: {
conditions: { permissions: 'admin' }, // Further restricts validation
type: ObjectId,
ref: 'User'
}
});
License
Mongoose Ref Validator is released under the MIT license.