'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 字典表 const DictionarySchema = { type: { type: String, required: true, maxLength: 200 }, // 类型 name: { type: String, required: true, maxLength: 200 }, // 名称 code: { type: String, required: false, maxLength: 200 }, // 代码 pcode: { type: String, required: false, maxLength: 200 }, // 前一级code }; const schema = new Schema(DictionarySchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Dictionary', schema, 'dictionary'); };