'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose/lib/model/schema'); const { ObjectId } = require('mongoose').Types; // 项目路演表 const road_show = { user_id: { type: ObjectId }, dock_id: { type: ObjectId }, // 展会id title: { type: String, required: false, maxLength: 500 }, // 标题 brief: { type: String, maxLength: 100 }, // 简介 origin: { type: String, required: false, maxLength: 500, default: '网站管理员' }, // 来源 publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间 content: { type: String, required: false }, // 正文 picture: { type: String, required: false }, // 图片路径 filepath: { type: String, required: false }, // 文件路径 remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(road_show, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ dock_id: 1 }); schema.index({ title: 1 }); schema.index({ origin: 1 }); schema.index({ publish_time: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Road_show', schema, 'road_show'); };