'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 权限表 const RoleSchema = { code: { type: String, required: false, maxLength: 200 }, // 权限CODE role_name: { type: String, required: true, maxLength: 64 }, // 权限名称 url: { type: String, required: false }, // 权限路由 }; const schema = new Schema(RoleSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ code: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Role', schema, 'role'); };