place.js 646 B

12345678910111213141516171819
  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. code: { type: String },
  8. name: { type: String },
  9. remark: { type: String, maxLength: 200 },
  10. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  11. };
  12. const schema = new Schema(xzqh, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.plugin(metaPlugin);
  16. module.exports = app => {
  17. const { mongoose } = app;
  18. return mongoose.model('Place', schema, 'place');
  19. };