'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 专利表 const PatentSchema = { create_number: { type: String, required: false }, // 申请号 create_date: { type: String, required: false }, // 申请日 success_number: { type: String, required: false }, // 公开(公告)号 success_date: { type: String, required: false }, // 公开(公告)日 name: { type: String, required: false }, // 标题 inventor: { type: String, required: false }, // 发明人 address: { type: String, required: false }, // 发明人地址 apply_personal: { type: String, required: false }, // 申请人 term: { type: String, required: false }, // 专利有效性 type: { type: String, required: false }, // 专利类型 agent_personal: { type: String, required: false }, // 代理人 agent: { type: String, required: false }, // 代理机构 abstract: { type: String, required: false }, // 摘要 img_url: { type: String, required: false }, // 图片 origin: { type: String }, // 数据来源(手写的) user_id: { type: [ ObjectId ] }, }; const schema = new Schema(PatentSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Patent', schema, 'patent'); };