'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 智库视点表 const view_point = { user_id: { type: ObjectId }, // title: { type: String }, // 标题 publish_time: { type: String }, // 时间 origin: { type: String, default: '网站管理员' }, // 来源 brief: { type: String }, // 简介 is_money: { type: Boolean, default: false }, // 是否收费 money_url: { type: String }, // 收款图片 picture: { type: Object }, // 图片 filepath: { type: Object }, // 附件 video: { type: Object }, // 视频 content: { type: String }, // 正文内容 remark: { type: String }, create_time: { type: String }, // 创建时间 }; const schema = new Schema(view_point, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ title: 1 }); schema.index({ publish_time: 1 }); schema.index({ origin: 1 }); schema.index({ is_money: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('ViewPoint', schema, 'viewPoint'); };