1234567891011121314151617181920 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 字典表
- const dict = {
- label: { type: String, required: false, zh: '字典名称' }, //
- code: { type: String, required: false, zh: '字典编码' }, //
- list: { type: Array, required: false, zh: '字典选项' }, //
- };
- const schema = new Schema(dict, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ code: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Dict', schema, 'dict');
- };
|