1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- const { ObjectId } = require('mongoose').Types;
- // 信息表
- const news = {
- column_id: { type: String, required: false, default: "" }, //栏目id
- column_name: { type: String, required: false, default: "" }, //栏目名称
- title: { type: String, required: false, default: "" }, //信息标题
- type: { type: String, required: false, default: "" }, //信息类型,国家,科学院
- release_time: { type: String, required: false, default: "" }, //发布时间
- origin: { type: String, required: false, default: "网站管理员" }, //信息来源
- brief: { type: String, required: false, default: "" }, //信息简介
- img_url: { type: Array, required: false, default: [] }, //图片文件
- video_url: { type: Array, required: false, default: [] }, //视频文件
- file_url: { type: Array, required: false, default: [] }, //附件文件
- content: { type: String, required: false, default: "" }, //信息内容
- is_money: { type: String, required: false, default: "" }, //是否收费
- money_url: { type: Array, required: false, default: [] }, //收费图片
- dock_id: { type: String, required: false, default: "" }, //展会id
- is_use: { type: String, required: false, default: "1" }, //是否禁用
- user_id: { type: String, required: false, default: "" }, //用户id
- remark: { type: String, maxLength: 200 },
- create_time: { type: String },
- };
- const schema = new Schema(news, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ column_id: 1 });
- schema.index({ type: 1 });
- schema.index({ dock_id: 1 });
- schema.index({ is_use: 1 });
- schema.index({ user_id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('News', schema, 'news');
- };
|