Melvin
Melvin
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
Yeah that's what I ended up doing.
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
I was able to with the complex query. Only downside is I now need to manipulate the data into the shape I need.
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
is that possible?
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
Looking at the roles example, lets say I want to get back
{ userId: 1, groupId: 1, roles: ["Admin", "Manager"] }
{ userId: 1, groupId: 1, roles: ["Admin", "Manager"] }
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
With the join approach, is it possible to select columns from the joined tables?
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
hmmm, okay that confirms one of the tests I just did.
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
where does the query get generated, maybe I can step through dn see what I'm doing wrong
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
hmm, still getting the same error with my initial query
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
hmm still running into this issue
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
Also for my understanding why was it trying to select(?) that column from my users table?
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
This is great! And if my users have roles which have permissions, can I include the permissions of the roles within my selection of the roles relationship?
20 replies
DTDrizzle Team
Created by Melvin on 7/18/2024 in #help
Querying relations
Generated sql for more context:
Query: select "users"."id", "users"."name", "users"."entra_user_id", "users"."email", "users_organizations"."data" as "organizations", "users_groups"."data" as "groups", "users_roles"."data" as "roles" from "users" left join lateral (select coalesce(json_agg(json_build_array("users_organizations"."user_id", "users_organizations"."organization_id")), '[]'::json) as "data" from "users_organizations" where "users_organizations"."user_id" = "users"."id") "users_organizations" on true left join lateral (select coalesce(json_agg(json_build_array("users_groups"."group_id", "users_groups"."user_id")), '[]'::json) as "data" from "users_groups" where "users_groups"."user_id" = "users"."id") "users_groups" on true left join lateral (select coalesce(json_agg(json_build_array("users_roles"."user_id", "users_roles"."role_id")), '[]'::json) as "data" from "users_roles" where "users_roles"."user_id" = "users"."id") "users_roles" on true where "users"."group_id" = $1 -- params: [""]
Query: select "users"."id", "users"."name", "users"."entra_user_id", "users"."email", "users_organizations"."data" as "organizations", "users_groups"."data" as "groups", "users_roles"."data" as "roles" from "users" left join lateral (select coalesce(json_agg(json_build_array("users_organizations"."user_id", "users_organizations"."organization_id")), '[]'::json) as "data" from "users_organizations" where "users_organizations"."user_id" = "users"."id") "users_organizations" on true left join lateral (select coalesce(json_agg(json_build_array("users_groups"."group_id", "users_groups"."user_id")), '[]'::json) as "data" from "users_groups" where "users_groups"."user_id" = "users"."id") "users_groups" on true left join lateral (select coalesce(json_agg(json_build_array("users_roles"."user_id", "users_roles"."role_id")), '[]'::json) as "data" from "users_roles" where "users_roles"."user_id" = "users"."id") "users_roles" on true where "users"."group_id" = $1 -- params: [""]
20 replies