personchat.js 829 B

12345678910111213141516171819
  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. receiver_id: { type: String, required: true, maxLength: 200 }, // 接收人id
  7. personroom_id: { type: String, required: true, maxLength: 200 }, // 聊天房间id
  8. content: { type: String, required: true, maxLength: 1000 }, // 发言内容
  9. status: { type: String, required: false, maxLength: 100, default: '0' }, // 状态,0-未读,1-已读
  10. };
  11. const schema = new Schema(Personchat, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Personchat', schema, 'person_chat');
  17. };