nation.js 549 B

12345678910111213141516171819
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 民族表
  5. const NationSchema = {
  6. code: { type: String, required: false, maxLength: 500 }, // 代码
  7. name: { type: String, required: false, maxLength: 500 }, // 名称
  8. };
  9. const schema = new Schema(NationSchema, { toJSON: { virtuals: true } });
  10. schema.index({ id: 1 });
  11. schema.plugin(metaPlugin);
  12. module.exports = app => {
  13. const { mongoose } = app;
  14. return mongoose.model('Nation', schema, 'nation');
  15. };