'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 purchase = { user_id: { type: ObjectId }, // 用户id demand: { type: String }, // 求购专利要求 type: { type: String }, // 专利类型 purchase_type: { type: String }, // 求购类型:许可,转移,质押 money: { type: String }, // 预算金额 contacts: { type: String }, // 联系人 phone: { type: String }, // 手机号 email: { type: String }, // 邮箱 status: { type: String }, // 状态 remark: { type: String }, }; const schema = new Schema(purchase, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ user_id: 1 }); schema.index({ type: 1 }); schema.index({ purchase_type: 1 }); schema.index({ contacts: 1 }); schema.index({ status: 1 }); schema.index({ money: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('PatentPurchase', schema, 'patent_purchase'); };