dimension.js 1.0 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 dimension = {
  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_show: { type: Boolean, default: false }, // 是否展示
  14. filepath: { type: Object }, // 附件
  15. content: { type: String }, // 正文内容
  16. remark: { type: String },
  17. create_time: { type: String }, // 创建时间
  18. };
  19. const schema = new Schema(dimension, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ title: 1 });
  22. schema.index({ publish_time: 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('Dimension', schema, 'dimension');
  29. };