personchat.js 1.1 KB

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