'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const ChatSchema = { roomid: { type: String, required: false, maxLength: 200 }, // 房间名称 type: { type: String, required: false, maxLength: 64 }, // 类型0、直播1、会议 content: { type: String, required: false, maxLength: 200 }, // 封面图片 sendid: { type: String, required: false, maxLength: 200 }, // 发送人id sendname: { type: String, required: false, maxLength: 200 }, // 发送人 sendtime: { type: String, required: false, maxLength: 200 }, // 发送时间 }; const schema = new Schema(ChatSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Chat', schema, 'chat'); };