dock_chat.js 996 B

12345678910111213141516171819202122232425
  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. // 展会公共聊天表
  7. const dock_chat = {
  8. dock_id: { type: ObjectId, required: true }, // 展会id
  9. content: { type: String, required: true }, // 内容
  10. sender_id: { type: String, required: true }, // 发送人id
  11. sender_name: { type: String, required: true }, // 发送人
  12. remark: { type: String, maxLength: 200 },
  13. send_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  14. };
  15. const schema = new Schema(dock_chat, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ dock_id: 1 });
  18. schema.index({ send_time: 1 });
  19. schema.index({ sender_id: 1 });
  20. schema.index({ 'meta.createdAt': 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Dock_chat', schema, 'dock_chat');
  25. };