Jan Vorwerk
Jan Vorwerk
DTDrizzle Team
Created by sevenwestonroads on 4/23/2023 in #help
UPSERT many ?
@fawwaz , apologies for my very late response... I missed your reply. Honnestly? I really don't know! 😅 That's why, it seems better that the framework deals with this for us (me)
14 replies
DTDrizzle Team
Created by Julio2049 on 11/3/2023 in #help
migrate with node-postgres
The push command is very nice but it is not enough if you need to modify the generated migration SQL files (for instance to add data migrations)
10 replies
DTDrizzle Team
Created by Julio2049 on 11/3/2023 in #help
migrate with node-postgres
Had the exact same issue... the woraround to use the Pool({max: 1}) worked for me!
10 replies
DTDrizzle Team
Created by sevenwestonroads on 4/23/2023 in #help
UPSERT many ?
14 replies
DTDrizzle Team
Created by sevenwestonroads on 4/23/2023 in #help
UPSERT many ?
Hello, I am resurecting an old discussion... How would you deal with a systematic update of all fields when you pass in an object? I came up with something like that:
await db
.insert(crmCompanies)
.values(values)
.onConflictDoUpdate({
target: crmCompanies.id,
set: Object.assign(
{},
...Object.keys(values[0])
.filter((k) => k !== "id")
.map((k) => ({ [k]: sql`excluded.${k}` })),
) as Partial<CrmCompanies>,
});
await db
.insert(crmCompanies)
.values(values)
.onConflictDoUpdate({
target: crmCompanies.id,
set: Object.assign(
{},
...Object.keys(values[0])
.filter((k) => k !== "id")
.map((k) => ({ [k]: sql`excluded.${k}` })),
) as Partial<CrmCompanies>,
});
Would it not make sense to have this directly available in Drizzle? Thanks!!
14 replies