Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when new user first time get money so its get error #27

Open
dev-Shivam999 opened this issue Oct 15, 2024 · 1 comment
Open

when new user first time get money so its get error #27

dev-Shivam999 opened this issue Oct 15, 2024 · 1 comment

Comments

@dev-Shivam999
Copy link

await db.$transaction([
db.balance.updateMany({
where: {
userId: Number(paymentInformation.userId)
},
data: {
amount: {
// You can also get this from your DB
increment: Number(paymentInformation.amount)
}
}
}),
db.onRampTransaction.updateMany({
where: {
token: paymentInformation.token
},
data: {
status: "Success",
}
})
]);

@dev-Shivam999
Copy link
Author

use upsert not updateMany

await db.$transaction([
db.balance.upsert({
where: {
userId: Number(paymentInformation.userId)
},
update: {

                amount: {
                    increment: Number(paymentInformation.amount)
                },


            }, create: {
                amount: Number(paymentInformation.amount),
                locked: 0,
                user: {
                    connect: {
                        id: Number(paymentInformation.userId),
                    },
                },
            },
        }),
        db.onRampTransaction.updateMany({
            where: {
                token: paymentInformation.token
            },
            data: {
                status: "Success",

            }
        })
    ]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant