1
votes

I have two resources in my system users and organizations. Each has a name and a relation with the other (many to many).

In my REST API I have:

/organizations - returns all organizations in the system (public)

/users - return all users in the system (public)

After this I needed to add properties to the relation (e.g. role in the organization). For this I created the concept of worker, a person in an organization.

What I have tried:

  • A new model, a "full resource"; it doesn't comply with a good rest design.
  • A nested resource inside organizations; better in json, but in Ember using EmbeddedRecordsMixin I lose the ability to manipulate the model - e.g. usage of adapter or serializer to change the resource.

How to design the REST api?

How to define Ember models and how to manipulate them?

1

1 Answers

0
votes
  1. Suggest making a 3rd resource that contains the role properties and relations to user and organization

  2. You can use links, an example response for an organization:

    {
        id: 1,
        links: {
            users: "/organizations/1/users"
        }
    }