customer_chat.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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 customer_chat = {
  8. _tenant: { type: String }, // 项目
  9. client_id: { type: ObjectId }, // 客户id
  10. client_name: { type: String }, // 客户名
  11. customer_id: { type: ObjectId }, // 客服id
  12. customer_name: { type: String }, // 客服名
  13. sender_id: { type: ObjectId }, // 发送人id
  14. sender_name: { type: String }, // 发送人
  15. content: { type: String }, // 内容
  16. remark: { type: String },
  17. };
  18. const schema = new Schema(customer_chat, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ _tenant: 1 });
  21. schema.index({ client_id: 1 });
  22. schema.index({ client_name: 1 });
  23. schema.index({ customer_id: 1 });
  24. schema.index({ customer_name: 1 });
  25. schema.index({ sender_id: 1 });
  26. schema.index({ sender_name: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('Customer_chat', schema, 'customer_chat');
  32. };