refute.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 文字/辟谣表
  7. const refute = {
  8. user_id: { type: ObjectId },
  9. title: { type: String }, // 标题
  10. origin: { type: String }, // 来源
  11. renew_time: { type: String }, // 更新时间
  12. content: { type: String }, // 内容
  13. website: { type: String }, // 文字网址
  14. fileUrl: { type: String }, // 文章视频
  15. imgUrl: { type: String }, // 图片
  16. read: { type: Number, default: 0 }, // 阅读数
  17. remark: { type: String, maxLength: 200 },
  18. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  19. };
  20. const schema = new Schema(refute, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ title: 1 });
  23. schema.index({ origin: 1 });
  24. schema.index({ 'meta.createdAt': 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('Refute', schema, 'refute');
  29. };