role.js 639 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 权限表
  5. const RoleSchema = {
  6. code: { type: String, required: false, maxLength: 200 }, // 权限CODE
  7. role_name: { type: String, required: true, maxLength: 64 }, // 权限名称
  8. url: { type: String, required: false }, // 权限路由
  9. };
  10. const schema = new Schema(RoleSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ code: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Role', schema, 'role');
  17. };