xzqh.js 794 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 行政区划表
  6. const xzqh = {
  7. name: { type: String, maxLength: 200 },
  8. code: { type: String, maxLength: 200 },
  9. pcode: { type: String, maxLength: 200 },
  10. disabled: { type: Boolean, default: false }, // false:使用;true:禁用
  11. remark: { type: String, maxLength: 200 },
  12. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  13. };
  14. const schema = new Schema(xzqh, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('Xzqh', schema, 'xzqh');
  21. };