set.js 761 B

1234567891011121314151617181920
  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 set = {
  7. title: { type: String }, // 套餐标题
  8. contact: { type: String }, // 关联的市/直辖市 的code
  9. has_group: { type: Boolean, default: false }, // 是否有推广制度
  10. remark: { type: String, maxLength: 200 },
  11. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  12. };
  13. const schema = new Schema(set, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('Set', schema, 'set');
  20. };