patentearly.js 1.0 KB

123456789101112131415161718192021222324252627
  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 patentearly = {
  8. parent_id: { type: ObjectId }, // 专利id
  9. name: { type: String }, // 专利名称
  10. inventor: { type: String }, // 发明人
  11. lose_date: { type: String }, // 截止时间
  12. content: { type: String }, // 预警消息
  13. early_num: { type: String }, // 预警次数,1:三个月,2:两个月,3:一个月
  14. user_id: { type: [ ObjectId ] }, // 接收人id
  15. remark: { type: String },
  16. };
  17. const schema = new Schema(patentearly, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.index({ parent_id: 1 });
  20. schema.index({ name: 1 });
  21. schema.index({ inventor: 1 });
  22. schema.index({ 'meta.createdAt': 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Patentearly', schema, 'patent_early');
  27. };