dictionary.js 996 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 Dictionary = {
  6. categroy: { type: String, required: false, maxLength: 200 }, // 字典代码
  7. pid: { type: String, required: false, maxLength: 200 }, // 上级
  8. label: { type: String, required: false, maxLength: 200 }, // 显示内容
  9. value: { type: String, required: false, maxLength: 200 }, // 存储内容
  10. status: { type: String, required: true, maxLength: 200, default: '使用' }, // 状态:使用;
  11. dstatus: { type: Boolean, default: false }, // 可删除权限,true:只有开发模式和修改数据库可以进行数据本体操作,否则不允许用户使用,哪怕是用户管理员
  12. };
  13. const schema = new Schema(Dictionary, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Dictionary', schema, 'dictionary');
  19. };