'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 用户特定权限 const UserMenu = { project: { type: String, required: true, maxLength: 200 }, // 项目名 userid: { type: String, required: true, maxLength: 200 }, // 用户id menu: { type: Array, required: true }, // 菜单标题 params: { type: Object }, // 参数字段,需要就用,不需要就不用 }; const schema = new Schema(UserMenu, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('UserMenu', schema, 'user_menu'); };