character.js 638 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. // 用户角色表
  6. const CharacterSchema = {
  7. name: { type: String, required: true, maxLength: 200 }, // 角色名称
  8. roles: { type: [ String ], required: false }, // 角色权限
  9. };
  10. const schema = new Schema(CharacterSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Character', schema, 'character');
  16. };