region.js 700 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  5. // 地区管理表
  6. const RegionSchema = {
  7. name: { type: String, required: true, maxLength: 200 }, // 地区名称
  8. url: { type: String, required: false, maxLength: 200 }, // 路径
  9. order: { type: String, required: false, maxLength: 200 }, // 顺序
  10. };
  11. const schema = new Schema(RegionSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Region', schema, 'region');
  17. };