dock.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. const { ObjectId } = require('mongoose').Types;
  6. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  7. // 展会表
  8. const dock = {
  9. room_id: { type: String, required: true }, // 房间号
  10. password: { type: Secret, select: false }, // 密码
  11. title: { type: String, required: false, maxLength: 200 }, // 对接会标题
  12. start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
  13. end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
  14. province: { type: String, required: false }, // 省
  15. city: { type: String, required: false }, // 市
  16. admin: { type: String, required: false, maxLength: 200 }, // 负责人
  17. phone: { type: String, required: false, maxLength: 200 }, // 负责人电话
  18. sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
  19. organizer: { type: String, required: false, maxLength: 200 }, // 承办方
  20. user_id: { type: ObjectId }, // 创建人
  21. status: { type: String, default: '0' }, // 0-准备中;1-开始;-1-结束
  22. remark: { type: String },
  23. };
  24. const schema = new Schema(dock, { toJSON: { virtuals: true } });
  25. schema.index({ id: 1 });
  26. schema.index({ room_id: 1 });
  27. schema.index({ title: 1 });
  28. schema.index({ start_time: 1 });
  29. schema.index({ end_time: 1 });
  30. schema.index({ admin: 1 });
  31. schema.index({ sponsor: 1 });
  32. schema.index({ user_id: 1 });
  33. schema.index({ status: 1 });
  34. schema.index({ 'meta.createdAt': 1 });
  35. schema.plugin(metaPlugin);
  36. module.exports = app => {
  37. const { mongoose } = app;
  38. return mongoose.model('Dock', schema, 'dock');
  39. };