|
@@ -0,0 +1,25 @@
|
|
|
+'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 dock_chat = {
|
|
|
+ dock_id: { type: ObjectId, required: true }, // 展会id
|
|
|
+ content: { type: String, required: true }, // 内容
|
|
|
+ sender_id: { type: String, required: true }, // 发送人id
|
|
|
+ sender_name: { type: String, required: true }, // 发送人
|
|
|
+ remark: { type: String, maxLength: 200 },
|
|
|
+ send_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
|
|
|
+};
|
|
|
+const schema = new Schema(dock_chat, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ dock_id: 1 });
|
|
|
+schema.index({ send_time: 1 });
|
|
|
+schema.index({ sender_id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Dock_chat', schema, 'dock_chat');
|
|
|
+};
|