Nxia618
Nxia618
Explore posts from servers
HHono
Created by Nxia618 on 6/20/2024 in #help
Losing type information on Client for AppType
No description
7 replies
DTDrizzle Team
Created by Nxia618 on 11/7/2023 in #help
Nested where filter, how to not include empty
The following almost works
const query = db.query.productionItem.findMany({
with: {
itemStages: {
where: eq(itemStage.crew_id, input.crew_id),
},
},
});
const query = db.query.productionItem.findMany({
with: {
itemStages: {
where: eq(itemStage.crew_id, input.crew_id),
},
},
});
I get only those productionItems with itemStage of particular crew_id, but I also get those with no itemStage's so query result has itemStages: []. How do I only include if crew_id equal and productionItem has itemStage
9 replies
DTDrizzle Team
Created by Nxia618 on 5/11/2023 in #help
numeric returns string when querying with Postgres
export const order = pgTable(
'orders', {
...
totalValue: numeric('total_value', { precision: 10, scale: 2 }),
...
})
export const order = pgTable(
'orders', {
...
totalValue: numeric('total_value', { precision: 10, scale: 2 }),
...
})
inspecting order.totalValue I get type
PgNumeric<{
tableName: "orders";
name: "total_value";
data: string;
driverParam: string;
notNull: false;
hasDefault: false;
}>
PgNumeric<{
tableName: "orders";
name: "total_value";
data: string;
driverParam: string;
notNull: false;
hasDefault: false;
}>
but when I do a query such as
await db
.insert(order)
.values({
...input,
})
.returning();
await db
.insert(order)
.values({
...input,
})
.returning();
The result is inferred as string | null for this column rather than number | null
2 replies