Ibad Shaikh
05/31/2021, 7:23 AM$transaction query.
My current code (which is not working yet) :
const _users_ = _await prisma.user.findMany_({
_select_:_ _{ _id_: _true_, _username_: _true_ },
_ _})
_for_ (const _u_ of users) {
let_ _uniqueId_ _= _nanoid_()
_await_ _prisma.user.update_({
where: { id: parseInt(_u._id) },
data: {
reference_code: uniqueId +-${_u._username}` + -${_u._id},},})`
}
_await_ _prisma.$transaction_([users])
Actually I want to update each user's reference_code ,for which I need its id and username.
How to access the id and username of the user which im currently updating?
From the docs I read that its not possible to grab id from find and the use it in update query.
How can I solve this?Ryan
05/31/2021, 7:36 AMIbad Shaikh
05/31/2021, 7:41 AMRyan
08/12/2021, 6:34 AM