magnetoise
magnetoise
Explore posts from servers
DTDrizzle Team
Created by magnetoise on 12/3/2024 in #help
with clause type not being inferred properly on insert
I have to assert it as a number for the type error to go away:
const countryIdQuery = db.$with('country_id').as(
db
.select({
id: countries.id,
})
.from(countries)
.where(eq(countries.code, data.countryCode)),
);

const [address] = await db
.with(countryIdQuery)
.insert(addresses)
.values({
addressLine1: data.addressLine1,
addressLine2: data.addressLine2,
city: data.city,
state: data.state,
postalCode: data.postalCode,
countryId: Number(countryIdQuery.id),
})
.returning({ id: addresses.id });

return address;
const countryIdQuery = db.$with('country_id').as(
db
.select({
id: countries.id,
})
.from(countries)
.where(eq(countries.code, data.countryCode)),
);

const [address] = await db
.with(countryIdQuery)
.insert(addresses)
.values({
addressLine1: data.addressLine1,
addressLine2: data.addressLine2,
city: data.city,
state: data.state,
postalCode: data.postalCode,
countryId: Number(countryIdQuery.id),
})
.returning({ id: addresses.id });

return address;
1 replies
DTDrizzle Team
Created by magnetoise on 9/23/2024 in #help
creating a synonym dictionary
how do I create a synonym dictionary in a drizzle schema? drizzle docs doesn't show anything on how I could create one
1 replies
DTDrizzle Team
Created by magnetoise on 9/18/2024 in #help
simplify fts query
my code feels more complex than it should be, can this be simplified further
3 replies
TtRPC
Created by magnetoise on 9/5/2024 in #❓-help
Caching API calls (HTTP response)
I'm using tRPC with Analog.js, I'm wondering if this is possible to be implemented. Where I could cache API calls, and clear cache on certain conditions (non-get request).
2 replies