123456789101112131415161718192021222324252627282930313233343536 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 在线表
- const online = {
- column_name: { type: String }, // 栏目名
- title: { type: String }, // 标题
- image: { type: Array }, // 封面
- organizers: { type: String }, // 举办方
- contacts: { type: String }, // 联系人
- phone: { type: String }, // 联系电话
- province: { type: String }, // 省
- city: { type: String }, // 市
- start_time: { type: String }, // 举办开始时间
- end_time: { type: String }, // 举办结束时间
- brief: { type: String }, // 信息简介
- video: { type: Array }, // 视频
- status: { type: String, default: '0' }, // 0:准备中;1:开始;2:结束
- remark: { type: String },
- create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(online, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ column_name: 1 });
- schema.index({ title: 1 });
- schema.index({ start_time: 1 });
- schema.index({ end_time: 1 });
- schema.index({ status: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Online', schema, 'online');
- };
|