Created
January 19, 2025 17:03
-
-
Save jmont96/c06e97d66460cd40e91e6a72357e9bad to your computer and use it in GitHub Desktop.
A sandbox file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function sandbox() { | |
await connect(process.env.MONGO_URI!); | |
const alerts: {alertId: string; paymentId: string}[] = []; | |
const paymentIds = alerts.map(alert => alert.paymentId); | |
const payments: CardPaymentDoc[] = await PaymentModel.find({ | |
_id: {$in: paymentIds}, | |
cardInfo: {$exists: true}, | |
}); | |
const promises = payments.map(payment => { | |
const alert = alerts.find(a => a.paymentId === payment._id.toString()); | |
if (!alert) return; | |
payment.cardInfo.fraudReport = { | |
requestId: alert.alertId, | |
report: {}, | |
}; | |
return payment.save(); | |
}); | |
await Promise.all(promises); | |
} |
ah yes
Maybe also verify that the record wasn't already fraud alerted
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const alert = alerts.find(a => a.paymentId === payment._id.toString());
const alert = alerts.find(a => a.paymentId === payment.paymentId.toString());