role.js 691 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 角色表
  7. const role = {
  8. name: { type: String, zh: '名称' }, // 名称
  9. brief: { type: String, zh: '简介' }, // 简介
  10. menu: { type: Array, zh: '菜单' }, // 菜单
  11. remark: { type: String },
  12. };
  13. const schema = new Schema(role, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('Role', schema, 'role');
  20. };