1234567891011121314151617181920212223242526 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 培训问诊聊天记录表
- const train_chat = {
- unit_id: { type: String, maxLength: 200 }, // 公共聊天区id
- sender_id: { type: String, maxLength: 200 }, // 发言人id
- sender_name: { type: String, required: true, maxLength: 200 }, // 发言人名称
- content: { type: String, required: true, maxLength: 1000 }, // 发言内容
- send_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss'), maxLength: 100 }, // 发言时间:年月日时分秒
- role: { type: String, maxLength: 200 }, // 用户身份
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(train_chat, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ unit_id: 1 });
- schema.index({ sender_id: 1 });
- schema.index({ send_time: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Train_chat', schema, 'train_chat');
- };
|