12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 字典目录
- const dictIndex = {
- name: { type: String, required: false, zh: '目录名称' }, //
- code: { type: String, required: false, zh: '目录编码' }, //
- status: { type: String, required: false, default: '0', zh: '状态' }, // 0:正常;1:停用
- };
- const schema = new Schema(dictIndex, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ code: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('DictIndex', schema, 'dictIndex');
- };
|