I have two microservices, lets call them “accounts” and “posts”
The “accounts-service” has it’s own database and handles “users” and “organizations”. Users can be a member of one or more organization.
The “posts-service” also has it’s own database and handles “posts” and “comments”. Both posts and comments have a creator which references a user id. Comments belong to a post. Posts belong to an organization by referencing an organization id.
I know how to setup the relationships between things in the same service, but I don’t know the best way to set up the relationships between resources in different services.
For instance, should a post have an attribute for “organizationId” or should it have a relationship for “organization”? If it should be under relationships, how to I do things like compound documents where a client asks for a post to include the organization (I don’t really want my microservices to be talking to eachother that much…but maybe I need to)?
Have same question here! o/
I have an Ember application already with several models and now a new Ember application will be born but this model that will be created will have a relationship with the existing ember application model.
Do you have a viable solution to this?
These two questions aren’t exactly the same.
For the first question about microservices: there’s no general solution. Using ember-data, you can have some Models that comes from one server and other Models that come from another (by customizing the adapters for each). They can relate to each other via JSON:API
links, and ember-data will respect that. For example
Note that it’s not important that your server actually speaks JSON:API in this way. Your serializer can translate whatever your server actually returns into this form, and that’s enough.
The second question is about sharing models between two Ember apps. The easiest way to do that is to put the models (and any adapters and serializers) into their own addon and use the addon in both apps.