HoaxKey
DTDrizzle Team
•Created by HoaxKey on 11/3/2024 in #help
Insert IF NOT EXISTS
I'm attempting to insert a row to a table, but only if a row doesnt already exist which has the same value for the column "content" and if it does, return that row like this:
const [resource] = await db
.insert(resources)
.values({ content: 'John Doe' })
.onConflictDoNothing({ target: resources.content })
.returning();
It doesn't seem to work, i dont get any errors but now i never seem to insert new rows or return existing rows. I'm brand new to Drizzle, what stupid mistake am I making?6 replies