train_chat.js 1.2 KB

1234567891011121314151617181920212223242526
  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 train_chat = {
  7. unit_id: { type: String, maxLength: 200 }, // 公共聊天区id
  8. sender_id: { type: String, maxLength: 200 }, // 发言人id
  9. sender_name: { type: String, required: true, maxLength: 200 }, // 发言人名称
  10. content: { type: String, required: true, maxLength: 1000 }, // 发言内容
  11. send_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss'), maxLength: 100 }, // 发言时间:年月日时分秒
  12. role: { type: String, maxLength: 200 }, // 用户身份
  13. remark: { type: String, maxLength: 200 },
  14. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  15. };
  16. const schema = new Schema(train_chat, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.index({ unit_id: 1 });
  19. schema.index({ sender_id: 1 });
  20. schema.index({ send_time: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Train_chat', schema, 'train_chat');
  26. };