record.js 853 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 聊天记录表
  5. const RecordSchema = {
  6. roomid: { type: String, required: true, maxLength: 200 }, // 房间id
  7. sendid: { type: String, required: true, maxLength: 200 }, // 发送者id
  8. receiveid: { type: String, required: true, maxLength: 200 }, // 接收者id
  9. type: { type: String, required: true, maxLength: 500 }, // 类型,0-学生向教师发送的信息,1-教师向学生发送的信息
  10. content: { type: String, required: false, maxLength: 2000 }, // 内容
  11. };
  12. const schema = new Schema(RecordSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Record', schema, 'record');
  18. };