Retrieve related records

Datasets can be related. In some cases you would like to combine information that comes from two related datasets. In the example below there is a one-to-many relationship between two datasets, "posts" and "comments". One post can have many comments and a comment belongs to one post. When fetching a related dataset, the JSON will contain a child object with the information from the related dataset.

Example:

[..]
let posts = dataModule.dataset("posts");
let comments = dataModule.dataset("comments");
posts.select().relation(comments).execute().then( (records) => {
  // objects in the records array will now contain a property called "comments"
  // which will be an array holding the comments related to a particular post.
});
[..]

A typical response will look like this:

[
    {
        "id": "127b54a4-f880-47ae-8760-89f42234a4af",
        "created_at": "2018-02-13T13:40:49.61886Z",
        "updated_at": null,
        "author": "The Author",
        "email": "theauthor@book.com",
        "comments": [
            {
                "id": "363cdcfa-9bf9-42b2-b69d-dd00fb811ca3",
                "created_at": "2018-02-13T14:26:25.07194Z",
                "updated_at": null,
                "comment": "My comment",
                "publishing_date": null,
                "post_id": "127b54a4-f880-47ae-8760-89f42234a4af"
            },
            {
                "id": "7b45cb5e-bab6-49d2-8c6d-0ecdbc771fa5",
                "created_at": "2018-02-13T13:37:24.99517Z",
                "updated_at": null,
                "comment": "A second comment",
                "publishing_date": null,
                "post_id": "127b54a4-f880-47ae-8760-89f42234a4af"
            }
        ]
    }
]


Advanced users:

In order to obtain deeper insights, please visit the API reference