'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 news = { title: { type: String }, // 标题 origin: { type: String }, // 来源 create_time: { type: String }, // 时间 content: { type: String }, // 内容 img: { type: Array }, // 图片,1张 type: { type: String, default: '0' }, // 类型:0-国内新闻;1-健康咨询 brief: { type: String }, // 简介 remark: { type: String }, }; const schema = new Schema(news, { 'multi-tenancy': true, toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ title: 1 }); schema.index({ type: 1 }); schema.index({ create_time: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('News', schema, 'news'); };