Mixed Nuts
Mixed Nuts
Explore posts from servers
KPCKevin Powell - Community
Created by Mixed Nuts on 4/3/2024 in #front-end
Color png
Ok sweet, thank you both, works great
5 replies
DTDrizzle Team
Created by Mixed Nuts on 2/17/2024 in #help
Multiple `onConflictDoUpdate()`
current solution, though I want to be able to input the table column names in a type safe way
const stmt = db.insert(characters).values(chars)
.onConflictDoUpdate({
target: characters.id,
set: {
name: sql`COALESCE(EXCLUDED.name, characters.name)`,
guildId: sql`COALESCE(EXCLUDED.guild_id, characters.guild_id)`,
level: sql`COALESCE(EXCLUDED.level,characters.level)`,
factionId: sql`COALESCE(EXCLUDED.faction_id,faction_id)`,
foreground: sql`COALESCE(EXCLUDED.foreground,characters.foreground)`,
background: sql`COALESCE(EXCLUDED.background,characters.background)`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
})
const stmt = db.insert(characters).values(chars)
.onConflictDoUpdate({
target: characters.id,
set: {
name: sql`COALESCE(EXCLUDED.name, characters.name)`,
guildId: sql`COALESCE(EXCLUDED.guild_id, characters.guild_id)`,
level: sql`COALESCE(EXCLUDED.level,characters.level)`,
factionId: sql`COALESCE(EXCLUDED.faction_id,faction_id)`,
foreground: sql`COALESCE(EXCLUDED.foreground,characters.foreground)`,
background: sql`COALESCE(EXCLUDED.background,characters.background)`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
})
4 replies
DTDrizzle Team
Created by Mixed Nuts on 2/17/2024 in #help
Multiple `onConflictDoUpdate()`
seems like trying to clean this up with a .$dynamic() doesn't work for .onConflictUpdate
4 replies