Conditionally throw error on D1 Batch Process

In Cloudflare D1, we do not have db.transaction and instead rely on db.batch. Cloudflare D1 rolls back if a statement in the batch errors. It is working ok, but I was wondering if it was possible to throw an error if a select returns zero results. E.g. checking if the user is owner of a certain record before proceeding into other updates
db.select().from(tables.lists).where(and(
eq(tables.lists.owner, userId),
eq(tables.lists.id, id)
)),
db.select().from(tables.lists).where(and(
eq(tables.lists.owner, userId),
eq(tables.lists.id, id)
)),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server