12345678910111213141516171819 |
- '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: true, maxLength: 64 }, // 类型0、直播1、会议
- content: { type: String, required: true, maxLength: 200 }, // 封面图片
- sendid: { type: String, required: true, maxLength: 200 }, // 发送人id
- };
- 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');
- };
|