UNPKG

sheercms

Version:

Sheer Cliff CMS is a simple and powerful content management system (CMS) for Node JS.

27 lines (21 loc) 630 B
var mongoose = require('mongoose'); var sysSchema = mongoose.Schema({ key: String, modified: Date, data: mongoose.Schema.Types.Mixed }); var models = { SysDoc: mongoose.model('sysdocs', sysSchema), }; //Unique Key Validation models.SysDoc.schema.path('key').validate(function (value, respond) { if (this.isNew == true) { models.SysDoc.findOne({ key: value }, function (err, result) { if (result) respond(false); else respond(true); }); } else respond(true); }, 'A sysdoc with this key already exists.'); module.exports = models;