'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 表 const dock_transcation = { dock_id: { type: ObjectId }, // 展会id product_id: { type: ObjectId }, // 产品id s_id: { type: ObjectId }, // 供给者id s_name: { type: String }, // 供给者姓名 s_phone: { type: String }, // 供给者电话 d_id: { type: ObjectId }, // 需求者id d_name: { type: String }, // 需求者姓名 d_phone: { type: String }, // 需求者电话 status: { type: String, default: '0' }, // 0-正在洽谈,1-达成意向,2-交易备案,3-交易完成,4-交易失败 contact: { type: String }, // 合同备份 remark: { type: String }, }; const schema = new Schema(dock_transcation, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ dock_id: 1 }); schema.index({ product_id: 1 }); schema.index({ s_id: 1 }); schema.index({ s_name: 1 }); schema.index({ d_id: 1 }); schema.index({ d_name: 1 }); schema.index({ status: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Dock_transcation', schema, 'dock_transcation'); };