'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 通知表 const patentnotice = { send_id: { type: ObjectId }, // 发送人id send_name: { type: String }, // 发送人姓名 to_type: { type: String }, // 0-所有人;1-机构用户;2-平台用户;3机构发给自己用户,4:科企发给个人用户 to_id: { type: [ ObjectId ] }, // 接收人id to_name: { type: String }, // 接收人姓名 is_read: { type: Boolean, default: false }, // 是否已读 content: { type: String }, // 内容 notice_file: { type: Array }, // 通知文件 remark: { type: String }, }; const schema = new Schema(patentnotice, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ send_id: 1 }); schema.index({ send_name: 1 }); schema.index({ to_type: 1 }); schema.index({ to_id: 1 }); schema.index({ is_read: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Patentnotice', schema, 'patent_notice'); };