Backendless Support
 
Waiting for user's response

Relation depth in repsonse from data item creation

Hi,

When I create an object in one of my tables, The newly created object is returned. However, the relation depth of the returned object only seems to be 1.

Is that correct? If so, can I change that somehow?

Kind regards,

Jeroen

Leave a Comment

Comments (2)

photo
1

Hi Jeroen

Could you please provide the code snippet you use to create an object ?

I was unable to reproduce your problem

I have tried with the following Data structur

  1. Order {
  2. name: String,
  3. items: ShoppingItem
  4. }
  5. ShoppingItem {
  6. price: Double,
  7. product: Product
  8. }
  9. Product {
  10. name: String
  11. }

then I create a new object and print the result into console like so: (JS)

  1. var serverOrder = Backendless.Data.of('Order').save({
  2. name: 'New Order',
  3. items: [{
  4. ___class: 'ShoppingItem',
  5. price: 10,
  6. product: {
  7. ___class: 'Product',
  8. name: 'BB'
  9. }
  10. }]
  11. })
  12. console.log(serverOrder)

The server's response includes all relations and their ids withing the response

photo
1

When I create the new object, the related objects already exist (a recording references a patient and a patient references a user), so I add it with only the ___class and objectId properties.

I add a recording object with a reference to an existing patient (using ___class and objectId as stated above). The patient has an existing relation to a user from the Users table. The returned object has all the properties of the patient filled in, but not its user reference. The user reference is not even present in the patient inside the returned recording object.

The analog in your example would be an existing ShippingItem with an existing relation to a Product. Then create a new Order with a reference to the existing ShippingItem. In my case, all relations are one-to-one though.

Kind regards,

Jeroen