chatroom.js 834 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 ChatroommSchema = {
  6. number: { type: String, required: false, maxLength: 200, default: new Date().getTime() }, // 房间号
  7. teacherid: { type: String, required: true, maxLength: 200 }, // 教师id
  8. teacher: { type: String, required: true, maxLength: 200 }, // 教师
  9. studentid: { type: String, required: true, maxLength: 200 }, // 学生id
  10. student: { type: String, required: true, maxLength: 200 }, // 学生
  11. };
  12. const schema = new Schema(ChatroommSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Chatroom', schema, 'chatroom');
  18. };