Aryan
Aryan
Explore posts from servers
DTDrizzle Team
Created by Aryan on 11/15/2024 in #help
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?
1 replies