'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 用户角色表 const CharacterSchema = { name: { type: String, required: true, maxLength: 200 }, // 角色名称 roles: { type: [ String ], required: false }, // 角色权限 }; const schema = new Schema(CharacterSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Character', schema, 'character'); };