'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 refute = { user_id: { type: ObjectId }, title: { type: String }, // 标题 origin: { type: String }, // 来源 renew_time: { type: String }, // 更新时间 content: { type: String }, // 内容 website: { type: String }, // 文字网址 fileUrl: { type: String }, // 文章视频 imgUrl: { type: String }, // 图片 read: { type: Number, default: 0 }, // 阅读数 remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(refute, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ title: 1 }); schema.index({ origin: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Refute', schema, 'refute'); };