open_info.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  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 open_info = {
  8. user_id: { type: ObjectId },
  9. column_name: { type: String }, // 栏目名称
  10. title: { type: String }, // 标题
  11. release_time: { type: String }, // 发布时间
  12. origin: { type: String }, // 来源
  13. content: { type: String }, // 内容
  14. image: { type: Array }, // 图片
  15. fileUrl: { type: Array }, // 附件
  16. remark: { type: String },
  17. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  18. };
  19. const schema = new Schema(open_info, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ user_id: 1 });
  22. schema.index({ column_name: 1 });
  23. schema.index({ origin: 1 });
  24. schema.index({ title: 1 });
  25. schema.index({ release_time: 1 });
  26. schema.index({ 'meta.createdAt': 1 });
  27. schema.plugin(metaPlugin);
  28. module.exports = app => {
  29. const { mongoose } = app;
  30. return mongoose.model('Open_info', schema, 'open_info');
  31. };