chat.js 705 B

12345678910111213141516171819
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const ChatSchema = {
  5. roomid: { type: String, required: false, maxLength: 200 }, // 房间名称
  6. type: { type: String, required: true, maxLength: 64 }, // 类型0、直播1、会议
  7. content: { type: String, required: true, maxLength: 200 }, // 封面图片
  8. sendid: { type: String, required: true, maxLength: 200 }, // 发送人id
  9. };
  10. const schema = new Schema(ChatSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Chat', schema, 'chat');
  16. };