1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const video = new Schema({
- video_title: { type: String, maxLength: 500 }, // 标题
- video_date: { type: String, maxLength: 500 }, // 时间
- video_url: { type: String, maxLength: 500 }, // 视频路径
- });
- const user = new Schema({
- user_title: { type: String, maxLength: 500 }, // 用户名
- user_phone: { type: String, maxLength: 500 }, // 账号
- user_password: { type: String, maxLength: 500 }, // 密码
- });
- // 培训问诊表
- const trainlive = {
- room_id: { type: String, required: true, unique: true }, // 房间号
- password: { type: String }, // 密码
- title: { type: String }, // 标题
- province: { type: String }, // 省份
- place: { type: String }, // 市区
- sponsor: { type: String }, // 主办方
- brief: { type: String }, // 简介
- user: { type: String }, // 负责人
- phone: { type: String }, // 负责人手机号
- video_data: { type: [ video ] }, // 视频
- user_data: { type: [ user ], select: false }, // 参加用户
- start_date: { type: String }, // 开始时间
- type: { type: String, default: 'train' }, // 类型
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(trainlive, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ room_id: 1 });
- schema.index({ title: 1 });
- schema.index({ province: 1 });
- schema.index({ city: 1 });
- schema.index({ user: 1 });
- schema.index({ phone: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Train_live', schema, 'train_live');
- };
|