news.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 信息表
  8. const news = {
  9. column_id: { type: String, required: false, default: "" }, //栏目id
  10. column_name: { type: String, required: false, default: "" }, //栏目名称
  11. title: { type: String, required: false, default: "" }, //信息标题
  12. type: { type: String, required: false, default: "" }, //信息类型,国家,科学院
  13. release_time: { type: String, required: false, default: "" }, //发布时间
  14. origin: { type: String, required: false, default: "网站管理员" }, //信息来源
  15. brief: { type: String, required: false, default: "" }, //信息简介
  16. img_url: { type: Array, required: false, default: [] }, //图片文件
  17. video_url: { type: Array, required: false, default: [] }, //视频文件
  18. file_url: { type: Array, required: false, default: [] }, //附件文件
  19. content: { type: String, required: false, default: "" }, //信息内容
  20. is_money: { type: String, required: false, default: "" }, //是否收费
  21. money_url: { type: Array, required: false, default: [] }, //收费图片
  22. dock_id: { type: String, required: false, default: "" }, //展会id
  23. is_use: { type: String, required: false, default: "1" }, //是否禁用
  24. user_id: { type: String, required: false, default: "" }, //用户id
  25. remark: { type: String, maxLength: 200 },
  26. create_time: { type: String },
  27. };
  28. const schema = new Schema(news, { toJSON: { virtuals: true } });
  29. schema.index({ id: 1 });
  30. schema.index({ column_id: 1 });
  31. schema.index({ type: 1 });
  32. schema.index({ dock_id: 1 });
  33. schema.index({ is_use: 1 });
  34. schema.index({ user_id: 1 });
  35. schema.index({ 'meta.createdAt': 1 });
  36. schema.plugin(metaPlugin);
  37. module.exports = app => {
  38. const { mongoose } = app;
  39. return mongoose.model('News', schema, 'news');
  40. };