Insert row, on conflict do nothing, and "return the conflicted row if it exists" - in 1 query?

Is it possible to do this query in one single Drizzle ORM query? Cus currently .onConflictDoNothing() is always returning an empty array for me (which I'm guessing is by design unless there's something else I could do) My best solution is probably using multiple ORM calls in a transaction for now, but was wondering if there was a way of doing this efficiently that I don't know about My query:
const data = await db
.insert(wishlist)
.values({
userId: userId,
})
.returning() // this returns succesfully if no conflicts
.onConflictDoNothing(); // can we somehow return the "conflicted" row?
const data = await db
.insert(wishlist)
.values({
userId: userId,
})
.returning() // this returns succesfully if no conflicts
.onConflictDoNothing(); // can we somehow return the "conflicted" row?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server