import mongoose from 'mongoose'; import db from '../db'; const ModelSchema = new mongoose.Schema({ group: {type: String, index: {unique: true}}, models: [new mongoose.Schema({ name: {type: String, index: {unique: true}}, url: String, label: String } ,{ _id : false })] }); // changelog query helper ModelSchema.query.log = function > (req) { db.log(req, this); return this; } ModelSchema.index({group: 1}); export default mongoose.model>('model', ModelSchema);