patentroom.js 1.1 KB

123456789101112131415161718192021222324252627282930
  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 { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 专利资讯服务房间表
  8. const patentroom = {
  9. time_id: { type: ObjectId }, // 时间id
  10. p1_id: { type: ObjectId, required: true }, // 第一个人id
  11. p1: { type: String, required: false }, // 第一个人名
  12. p2_id: { type: ObjectId, required: true }, // 第二个人id
  13. p2: { type: String, required: false }, // 第二个人名
  14. create_time: {
  15. type: String,
  16. default: moment().format('YYYY-MM-DD HH:mm:ss'),
  17. },
  18. last_time: { type: String }, // 最后发言时间
  19. };
  20. const schema = new Schema(patentroom, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ time_id: 1 });
  23. schema.index({ p1_id: 1 });
  24. schema.index({ p2_id: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Patentroom', schema, 'patent_room');
  30. };