Pupok
Pupok
Explore posts from servers
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
so is better to just create more queries for each field? i tried adding eta.roid and files.roid to the groupby but still getting duplicated entries 😦
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
hey @Raphaël M (@rphlmr) ⚡ sorry to bring this back, but sometimes the queries return duplicated item that dont exist in the db this is my query right now
const [data] = await db
.select({
...getTableColumns(repairOrder),
estimator: getTableColumns(estimator),
mechanic: getTableColumns(mechanic),
files: jsonAggBuildObject(getTableColumns(files)),
etas: jsonAggBuildObject(getTableColumns(eta))
})
.from(repairOrder)
.innerJoin(estimator, eq(estimator.id, repairOrder.userId))
.leftJoin(mechanic, eq(mechanic.id, repairOrder.mechanicId))
.leftJoin(files, eq(files.roId, repairOrder.id))
.leftJoin(eta, eq(eta.roId, repairOrder.id))
.groupBy(repairOrder.id, estimator.id, mechanic.id)
.where(eq(repairOrder.id, id))
const [data] = await db
.select({
...getTableColumns(repairOrder),
estimator: getTableColumns(estimator),
mechanic: getTableColumns(mechanic),
files: jsonAggBuildObject(getTableColumns(files)),
etas: jsonAggBuildObject(getTableColumns(eta))
})
.from(repairOrder)
.innerJoin(estimator, eq(estimator.id, repairOrder.userId))
.leftJoin(mechanic, eq(mechanic.id, repairOrder.mechanicId))
.leftJoin(files, eq(files.roId, repairOrder.id))
.leftJoin(eta, eq(eta.roId, repairOrder.id))
.groupBy(repairOrder.id, estimator.id, mechanic.id)
.where(eq(repairOrder.id, id))
files and etas sometimes return the same record 2 or 3 times, it only happen in some repairOrders not all of them
17 replies
DTDrizzle Team
Created by Pupok on 8/9/2024 in #help
Error migrating "type does not exist"
im going to check it out for sure, the app is on an early stage so we may implement this later, thanks alot
17 replies
DTDrizzle Team
Created by Pupok on 8/9/2024 in #help
Error migrating "type does not exist"
thanks !!
17 replies
DTDrizzle Team
Created by Pupok on 8/9/2024 in #help
Error migrating "type does not exist"
so even roId should be ro_id?
17 replies
DTDrizzle Team
Created by Pupok on 8/9/2024 in #help
Error migrating "type does not exist"
ill have to update alot of things, should i drop my supabase and rename everything and push new db schema ?
17 replies
DTDrizzle Team
Created by Pupok on 8/9/2024 in #help
Error migrating "type does not exist"
so i should be moving to snake case for everything ?
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
thanks you so much for the help!
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
i tested your suggestion and its working good, thanks i learned a lot here!, also is there a way for the util functions, to return empty array if there is no files? i tried to modify the functions but sql is beyond my knowdlge
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
I see in the code you sent, that there is a declaration for a relation, it's required or not ?
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
Yeah it is roId I had it correct in my code but since I removed it I just typed it directly here as an example
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
So if I'm not using RQB, i don't have to create the relations like I did ? So I don't have to create any relation ?
17 replies
DTDrizzle Team
Created by Pupok on 8/7/2024 in #help
Is this the right way of using relations ?
Any idea ?
17 replies