trainChat.js 893 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. // 培训问诊聊天记录表
  6. const train_chat = {
  7. train_id: { type: String, maxLength: 200 }, // 展会id
  8. sender_id: { type: String }, // 发送人id
  9. sender_name: { type: String }, // 发送人姓名
  10. content: { type: String }, // 发送内容
  11. send_time: { type: String }, //发送时间
  12. remark: { type: String, maxLength: 200 },
  13. };
  14. const schema = new Schema(train_chat, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ train_id: 1 });
  17. schema.index({ sender_id: 1 });
  18. schema.index({ sender_name: 1 });
  19. schema.index({ 'meta.createdAt': 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('TrainChat', schema, 'trainChat');
  24. };