Select with a join that returns eagerly loaded submodels

hey all, is it possible to do a select on a model using a join and return the model with eagerly loaded fk models. Something like this where I'm joing wharehouse to location to filter on location.city but i want the location to be returned nested in wharehouse not alongside getWarehousesInCity: publicProcedure .input(z.string()) .query(async ({ctx, input}) => { return await ctx.db.select({ warehouses, with:{ locations: true } }).from(warehouses).innerJoin(locations, eq(warehouses.location_id, locations.location_id)).where(eq(locations.city_id, input)).execute(); }),
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server