purchase.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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 purchase = {
  8. user_id: { type: ObjectId }, // 用户id
  9. demand: { type: String }, // 求购专利要求
  10. type: { type: String }, // 专利类型
  11. purchase_type: { type: String }, // 求购类型:许可,转移,质押
  12. money: { type: String }, // 预算金额
  13. contacts: { type: String }, // 联系人
  14. phone: { type: String }, // 手机号
  15. email: { type: String }, // 邮箱
  16. status: { type: String }, // 状态
  17. remark: { type: String },
  18. };
  19. const schema = new Schema(purchase, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ user_id: 1 });
  22. schema.index({ type: 1 });
  23. schema.index({ purchase_type: 1 });
  24. schema.index({ contacts: 1 });
  25. schema.index({ status: 1 });
  26. schema.index({ money: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('PatentPurchase', schema, 'patent_purchase');
  32. };