Eco 🌤
Eco 🌤
DTDrizzle Team
Created by Eco 🌤 on 10/14/2024 in #help
How to automatically run migration on NextJS start
No description
5 replies
DTDrizzle Team
Created by Eco 🌤 on 8/14/2024 in #help
can we have production migrations recommendations docs for drizzle?
No description
2 replies
DTDrizzle Team
Created by Eco 🌤 on 7/25/2024 in #help
separating relations to different file results in typescript issues
I have updated my config to this and just move the relations to relations.ts
schema: ["./server/db/schema.ts", "./server/db/relations.ts"],
schema: ["./server/db/schema.ts", "./server/db/relations.ts"],
It results in this kind of type error.
error TS2339: Property 'name' does not exist on type 'never'.

29 .map((p) => p.permission.name);
error TS2339: Property 'name' does not exist on type 'never'.

29 .map((p) => p.permission.name);
3 replies
DTDrizzle Team
Created by Eco 🌤 on 7/6/2024 in #help
Is it possible to return has many relationship load to return a single object instead of an array.
db.query.products.findMany({
orderBy: (model, { desc }) => desc(model.createdAt),
with: {
discounts: {
where: (model, { eq }) =>
eq(model.organizationId, session.organizationId),
limit: 1,
},
},
}),
db.query.products.findMany({
orderBy: (model, { desc }) => desc(model.createdAt),
with: {
discounts: {
where: (model, { eq }) =>
eq(model.organizationId, session.organizationId),
limit: 1,
},
},
}),
output
[
{
id: 1,
discounts: [ [Object] ]
}
]
[
{
id: 1,
discounts: [ [Object] ]
}
]
desired output
[
{
id: 1,
discounts: Object
}
]
[
{
id: 1,
discounts: Object
}
]
2 replies
DTDrizzle Team
Created by Eco 🌤 on 5/26/2024 in #help
How to properly infer type or add typings of a returned model with relationship in a component props
getCart.tsx
const session = await getSession();

let cart = await db.query.carts.findFirst({
where: (model, { eq }) => eq(model.userId, session.uuid),
with: {
items: {
with: {
product: true,
},
},
},
});

return cart;
const session = await getSession();

let cart = await db.query.carts.findFirst({
where: (model, { eq }) => eq(model.userId, session.uuid),
with: {
items: {
with: {
product: true,
},
},
},
});

return cart;
page.tsx
const cart = await getCart();
<CartSummary cart={cart} />
const cart = await getCart();
<CartSummary cart={cart} />
cart-summary.tsx
export default async function CartSummary({ cart }) {
}
export default async function CartSummary({ cart }) {
}
6 replies