123456789101112131415161718192021222324252627282930 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- const { ObjectId } = require('mongoose').Types;
- // 科技频道表
- const channel = {
- room_id: { type: String }, // 房间id,服务生成,从2001开始
- password: { type: Secret }, // 密码,房间号
- title: { type: String }, // 标题
- origin: { type: String }, // 来源
- type: { type: String }, // 类别
- brief: { type: String }, // 简介
- create_time: { type: String }, // 更新时间
- status: { type: String, default: '0' }, // 0-准备中;1-开始;-1-结束
- role: { type: String, required: false, default: '7' }, // 角色
- remark: { type: String },
- };
- const schema = new Schema(channel, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ room_id: 1 });
- schema.index({ title: 1 });
- schema.index({ type: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Channel', schema, 'channel');
- };
|