'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 培训问诊聊天记录表 const train_chat = { train_id: { type: String, maxLength: 200 }, // 展会id sender_id: { type: String }, // 发送人id sender_name: { type: String }, // 发送人姓名 content: { type: String }, // 发送内容 send_time: { type: String }, //发送时间 remark: { type: String, maxLength: 200 }, }; const schema = new Schema(train_chat, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ train_id: 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('TrainChat', schema, 'trainChat'); };