How to Add Objects With Relations Using REST Console

by on September 1, 2019

In another post, we described how to save data objects using REST Console. The same interface allows us to save objects with related data – it is strictly a matter of formatting the request body.

Consider the following two data table schemas:

Restaurant table schema:

Restaurant Table Schema

Notice the locations column, which represents a one-to-many relation with the Location table:

Location Table Schema

To save a new object in the Restaurant table using the REST Console in Backendless Console:

  1. Select the Restaurant table and click on the REST Console.
  2. Enter the following JSON object into the Request body field:
      "name":"Mama Mia Pizzeria",
           "streetAddress":"123 Main St",
           "city":"New York"

    Notice the locations element – it contains an array with one object. The reason for the array is the one-to-many relationship between the Restaurant and Location tables. Additionally, the object inside of the “locations” array contains a special property ___class. The property indicates that the object is an “instance” of the Location object and should be placed into the Locations table.

  3. Click the POST button to save the objects. You will see a response similar to the one in the screenshot below:

Leave a Reply