How to access multiple relations in query

Hi Team Recently i working with drizzle in my personal project. so i have three tables property, content and price. each property will related with one content and one price for the price i already define the schema in my schema.ts but then i cannot price table in my +page.server.ts (im using sveltekit) and only content table is accessible in my vscode autocomplete
No description
3 Replies
alka_99
alka_99OP12mo ago
AstroBear
AstroBear12mo ago
Because:
export const contentRelations = relations(property, ({ one }) => ({
content: one(content,{
fields: [property.id],
references: [content.property_id]
})
}))
export const contentRelations = relations(property, ({ one }) => ({
content: one(content,{
fields: [property.id],
references: [content.property_id]
})
}))
is actually a property relation (see relations(property, ...), while:
export const priceRelations = relations(price, ({ one }) => ({
property: one(property,{
fields: [price.property_id],
references: [property.id]
})
}))
export const priceRelations = relations(price, ({ one }) => ({
property: one(property,{
fields: [price.property_id],
references: [property.id]
})
}))
is a price relation. You need to fix contentRelations and create a new propertyRelations that references both content and price
alka_99
alka_99OP12mo ago
yep, i just realized that thank you for helping me now everything working perfectly
Want results from more Discord servers?
Add your server