'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 专利运营已授权专利预警表 const patentearly = { parent_id: { type: ObjectId }, // 专利id name: { type: String }, // 专利名称 inventor: { type: String }, // 发明人 lose_date: { type: String }, // 截止时间 content: { type: String }, // 预警消息 early_num: { type: String }, // 预警次数,1:三个月,2:两个月,3:一个月 user_id: { type: [ ObjectId ] }, // 接收人id remark: { type: String }, }; const schema = new Schema(patentearly, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ parent_id: 1 }); schema.index({ name: 1 }); schema.index({ inventor: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Patentearly', schema, 'patent_early'); };