const mongoose = require('mongoose');
 
const OrderReturnSchema = mongoose.Schema({
	userId:{
		type: String, 
	},
	merchantTransactionId:{
		type: String, 
	},
	amount:{
		type:Number
	}, 
	orderId:{
		type: String, 
	},
	status:{
		type: String, 
	},
	paymentDetails:{
		type: String, 
	},
	date_added:{
		type: Date,
		default: Date.now
	},
	host:{
		type: String
	}
});

OrderReturnSchema.post(['save','insertMany'],async function (doc){
    try{
        let returns = [];
        if(Array.isArray(doc)){
            returns = doc;
        } else {
            returns = [doc];
        }
    } catch(err){
        console.log(err);
    }
});
 
module.exports = mongoose.model('paymentGateway', OrderReturnSchema)
 
// cond = Condition