-
Notifications
You must be signed in to change notification settings - Fork 1
Description
A Book, for example, would have a related Author, which in turn might have a related Location record for the place of birth. When fetching a book, it may be useful to have jsonmonger include not only the author, but the author’s location. The tricky part of this is that jsonmonger can’t know which type might be related to a particular property, so the model itself needs to declare this in the related config somehow.
An object might be the way to go here. Using the example above:
const Author = new Model({
birthplace: 'relationships.location_born',
});
const Book = new Model({
author: 'relationships.author',
}, {
related: {
author: {
Author: 'birthplace',
},
},
});The result should be that the include query string param would look like this:
?include=author.location_born
which the API should use to include the related author and their related birthplace in the payload.
Suggestions welcome on this interface. I think it’s a bit awkward, but can’t think of another way to accomplish this.