Reizel
Reizel
DTDrizzle Team
Created by Reizel on 10/12/2024 in #help
How to update/insert id of a reference when I have a different constraint
As far as I can tell it does allow using the $with method: https://orm.drizzle.team/docs/update#with-update-clause But I just can't seem to get it to work, and also it's not typesafe at all unless I am doing something wrong?
8 replies
DTDrizzle Team
Created by Reizel on 10/12/2024 in #help
How to update/insert id of a reference when I have a different constraint
I am doing this for an array of items, not just one, so I would have to query for a lot of items. In prisma you would simply do this as:
await db.table.upsert({
where: {
appId,
// would find the achievement id via the unique constraint:
achievement: { appId, code },
},
})
await db.table.upsert({
where: {
appId,
// would find the achievement id via the unique constraint:
achievement: { appId, code },
},
})
Not sure if this is just Prisma abstracting and doing things client-side, or if there is a magic way of doing it using SQL. But it feels like this is way harder than it should be with Drizzle?
8 replies
DTDrizzle Team
Created by Reizel on 10/12/2024 in #help
How to update/insert id of a reference when I have a different constraint
Yes, good catch! It should reference table1. I have fixed it now! I tried using $with and the sql operator. But both still feel like magic and I couldn't find enough documentation online to be able to figure it out on my own. Would you be able to provide an example of how this should look like?
8 replies