1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 客服聊天记录表
- const customer_chat = {
- _tenant: { type: String }, // 项目
- client_id: { type: ObjectId }, // 客户id
- client_name: { type: String }, // 客户名
- customer_id: { type: ObjectId }, // 客服id
- customer_name: { type: String }, // 客服名
- sender_id: { type: ObjectId }, // 发送人id
- sender_name: { type: String }, // 发送人
- content: { type: String }, // 内容
- remark: { type: String },
- };
- const schema = new Schema(customer_chat, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ _tenant: 1 });
- schema.index({ client_id: 1 });
- schema.index({ client_name: 1 });
- schema.index({ customer_id: 1 });
- schema.index({ customer_name: 1 });
- schema.index({ sender_id: 1 });
- schema.index({ sender_name: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Customer_chat', schema, 'customer_chat');
- };
|