viewPoint.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 智库视点表
  7. const view_point = {
  8. user_id: { type: ObjectId }, //
  9. title: { type: String }, // 标题
  10. publish_time: { type: String }, // 时间
  11. origin: { type: String, default: '网站管理员' }, // 来源
  12. brief: { type: String }, // 简介
  13. is_money: { type: Boolean, default: false }, // 是否收费
  14. money_url: { type: String }, // 收款图片
  15. picture: { type: Object }, // 图片
  16. filepath: { type: Object }, // 附件
  17. video: { type: Object }, // 视频
  18. content: { type: String }, // 正文内容
  19. remark: { type: String },
  20. create_time: { type: String }, // 创建时间
  21. };
  22. const schema = new Schema(view_point, { toJSON: { virtuals: true } });
  23. schema.index({ id: 1 });
  24. schema.index({ title: 1 });
  25. schema.index({ publish_time: 1 });
  26. schema.index({ origin: 1 });
  27. schema.index({ is_money: 1 });
  28. schema.index({ 'meta.createdAt': 1 });
  29. schema.plugin(metaPlugin);
  30. module.exports = app => {
  31. const { mongoose } = app;
  32. return mongoose.model('ViewPoint', schema, 'viewPoint');
  33. };