dictIndex.js 752 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 字典目录
  5. const dictIndex = {
  6. name: { type: String, required: false, zh: '目录名称' }, //
  7. code: { type: String, required: false, zh: '目录编码' }, //
  8. status: { type: String, required: false, default: '0', zh: '状态' }, // 0:正常;1:停用
  9. };
  10. const schema = new Schema(dictIndex, { toJSON: { getters: true, virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ 'meta.createdAt': 1 });
  13. schema.index({ name: 1 });
  14. schema.index({ code: 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('DictIndex', schema, 'dictIndex');
  19. };