'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 RegionSchema = { name: { type: String, required: true, maxLength: 200 }, // 地区名称 url: { type: String, required: false, maxLength: 200 }, // 路径 order: { type: String, required: false, maxLength: 200 }, // 顺序 }; const schema = new Schema(RegionSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Region', schema, 'region'); };