dict.js 658 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 字典表
  5. const dict = {
  6. label: { type: String, required: false, zh: '字典名称' }, //
  7. code: { type: String, required: false, zh: '字典编码' }, //
  8. list: { type: Array, required: false, zh: '字典选项' }, //
  9. };
  10. const schema = new Schema(dict, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ 'meta.createdAt': 1 });
  13. schema.index({ code: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Dict', schema, 'dict');
  18. };