Mixed Nuts
Mixed Nuts
Explore posts from servers
KPCKevin Powell - Community
Created by Mixed Nuts on 4/3/2024 in #front-end
Color png
My restraints are kind of weird, but I have game file icons that I want to port to the browser. Its a crest data, that is two layers of png, background/foreground. The icons are white/black, and then use a rgba function to give the respective layer a color overlay. Is there a similiar way to do this that doesn't have me try to figure out a way to convert the rgba values to css filter functions dynamically during runtime?
5 replies
DTDrizzle Team
Created by Mixed Nuts on 2/22/2024 in #help
Select<Type> Help
Random, but how can I get this to be type safe?
type Reports = {
character: typeof characters.$inferSelect & {
faction: typeof factions.$inferSelect,
guild: typeof guilds.$inferSelect & {
faction: typeof factions.$inferSelect
}
},
log: typeof logs.$inferSelect
}
const characterFaction = alias(factions, 'characterFaction')
const guildFaction = alias(factions, 'guildFaction')

const preparedReports = db.select({
character: {
...characters,
faction: characterFaction,
guild: {
...guilds,
faction: guildFaction
}
},
log: logs

})
//...
type Reports = {
character: typeof characters.$inferSelect & {
faction: typeof factions.$inferSelect,
guild: typeof guilds.$inferSelect & {
faction: typeof factions.$inferSelect
}
},
log: typeof logs.$inferSelect
}
const characterFaction = alias(factions, 'characterFaction')
const guildFaction = alias(factions, 'guildFaction')

const preparedReports = db.select({
character: {
...characters,
faction: characterFaction,
guild: {
...guilds,
faction: guildFaction
}
},
log: logs

})
//...
I get the object exactly how I want it but just not the type safety where it knows the Reports type is the actual selected type
1 replies
DTDrizzle Team
Created by Mixed Nuts on 2/17/2024 in #help
Multiple `onConflictDoUpdate()`
Is there a cleaner way to do this? I tried case and where in the sql statements in one vs chaining, but that didn't work
const stmt = db.insert(characters).values(chars)
.onConflictDoUpdate({
target: characters.id,
set: {
name: sql`excluded.name`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.name is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
level: sql`excluded.level`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.level is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
factionId: sql`excluded.faction_id`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.faction_id is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
foreground: sql`excluded.foreground`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.foreground is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
background: sql`excluded.background`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.background is not null`
})
const stmt = db.insert(characters).values(chars)
.onConflictDoUpdate({
target: characters.id,
set: {
name: sql`excluded.name`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.name is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
level: sql`excluded.level`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.level is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
factionId: sql`excluded.faction_id`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.faction_id is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
foreground: sql`excluded.foreground`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.foreground is not null`
})
.onConflictDoUpdate({
target: characters.id,
set: {
background: sql`excluded.background`,
updatedAt: sql`CURRENT_TIMESTAMP`
},
where: sql`excluded.background is not null`
})
4 replies