Prepared Update statements

Is it possible to use preparad statements for updating data? I was able to use prepared statements with .select(), .findFirst(), or .findMany(), but I am having trouble with .update(). If possible, what would the syntax be? I am trying to update a verificationToken, and I would need two placeholders there. Tried something like this, but It's wrong:
export const psUpdateEmailVerificationToken = db.update(users).set({
emailVerificationToken: sql.placeholder("emailVerificationToken"),
}).where({
(users, {eq}) => eq(users.id, sql.placeholder("id"))
}).prepare("psUpdateEmailVerificationToken")
export const psUpdateEmailVerificationToken = db.update(users).set({
emailVerificationToken: sql.placeholder("emailVerificationToken"),
}).where({
(users, {eq}) => eq(users.id, sql.placeholder("id"))
}).prepare("psUpdateEmailVerificationToken")
Is this even possible? I am using Drizzle with Postrgres at Neon.
6 Replies
MAST
MAST15mo ago
I don't think that's possible. I haven't seen it anywhere.
Angelelz
Angelelz15mo ago
GitHub
drizzle-orm/drizzle-orm/src/pg-core/query-builders/update.ts at a7d...
TypeScript ORM that feels like writing SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
Angelelz
Angelelz15mo ago
And that's the correct syntax
MAST
MAST15mo ago
OH, that's nice.
CrisOG
CrisOG11mo ago
The placeholders don't seem to be supported tho, or am I doing something wrong? https://discord.com/channels/1043890932593987624/1202391466865860618
chronos
chronos10mo ago
Did you ever manage to resolve this? I am having the same issue.
Want results from more Discord servers?
Add your server