room.js 644 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 聊天房间表
  5. const RoomSchema = {
  6. teaid: { type: String, required: true, maxLength: 200 }, // 教师id
  7. stuid: { type: String, required: true, maxLength: 200 }, // 学生id
  8. status: { type: String, required: false, maxLength: 500 }, // 状态,0-开始,1-结束
  9. };
  10. const schema = new Schema(RoomSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Room', schema, 'room');
  16. };