patentnotice.js 1002 B

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 patentnotice = {
  8. send_id: { type: ObjectId }, // 发送人id
  9. send_name: { type: String }, // 发送人姓名
  10. to_type: { type: String }, // 0-所有人;1-机构用户;2-平台用户;3机构发给自己用户
  11. to_id: { type: [ ObjectId ] }, // 接收人id
  12. content: { type: String }, // 内容
  13. remark: { type: String },
  14. };
  15. const schema = new Schema(patentnotice, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ send_id: 1 });
  18. schema.index({ send_name: 1 });
  19. schema.index({ to_type: 1 });
  20. schema.index({ to_id: 1 });
  21. schema.index({ is_read: 1 });
  22. schema.index({ 'meta.createdAt': 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Patentnotice', schema, 'patent_notice');
  27. };