123456789101112131415161718192021 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 字典
- const Dictionary = {
- categroy: { type: String, required: false, maxLength: 200 }, // 字典代码
- pid: { type: String, required: false, maxLength: 200 }, // 上级
- label: { type: String, required: false, maxLength: 200 }, // 显示内容
- value: { type: String, required: false, maxLength: 200 }, // 存储内容
- status: { type: String, required: true, maxLength: 200, default: '使用' }, // 状态:使用;
- dstatus: { type: Boolean, default: false }, // 可删除权限,true:只有开发模式和修改数据库可以进行数据本体操作,否则不允许用户使用,哪怕是用户管理员
- };
- const schema = new Schema(Dictionary, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Dictionary', schema, 'dictionary');
- };
|