'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const Personchat = { sender_id: { type: String, required: true, maxLength: 200 }, // 发送人id sender_name: { type: String, required: false, maxLength: 200 }, // 发送人名字 receiver_id: { type: String, required: true, maxLength: 200 }, // 接收人id receiver_name: { type: String, required: false, maxLength: 200 }, // 接收人名字 personroom_id: { type: String, required: true, maxLength: 200 }, // 聊天房间id content: { type: String, required: true, maxLength: 1000 }, // 发言内容 send_time: { type: String, required: true, maxLength: 100 }, // 发言时间:年月日时分秒 status: { type: String, required: false, maxLength: 100, default: '0' }, // 状态,0-未读,1-已读 }; const schema = new Schema(Personchat, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Personchat', schema, 'person_chat'); };