Skip to content

How to convert an array with single item to object for embedded resource? #2917

Answered by laurenceisla
hambergerpls asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, I'm trying to fetch a user's role where

  1. roles has one-to-one relationship with organizations
  2. users has one-to-many relationship with organizations
  3. users has one-to-many relationship with roles

Hi, it looks like the table rel_roles_users is incompatible with these relationships you're defining. By having role_id, user_id, organization_id as primary keys you're making Many-To-Many relationships between roles->users and roles->organizations. Also I'm a bit confused about rule N°1, if a 'role_a' belongs to 'org_a' then 'org_a' cannot have any other roles, is that expected?

So, yes, I think you'll need to restructure your tables. You could keep public.rel_roles_users but without a comp…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hambergerpls
Comment options

Answer selected by hambergerpls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2910 on August 24, 2023 23:44.