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