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' },
- 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');
- };
|