How does relationsDepth work?


I am trying to understand how the parameter “relationsDepth” works . On my online console I have defined 3 objects in a 3-level nested relationship:

  1. TestMaster (top level)
  2. TestChildLevel1 ( related to TestMaster, first level)
  3. TestChildLevel2 (related to ChildObjLevel1, second level)

When I run a query using relationsDepth = 2, details objects are not fetched (specifically TestChildLevel1 is an empty array). Here is a simplified version of my code (javascript-typescript es5):

var query = new Backendless.DataQuery();
query.options ={
relationsDepth: 2
Backendless.Persistence.of('TestMaster').find( query, ...)

But when I explicitly mention “TestChildLevel1” via the options.relations array in the option query, then this detail is properly returned, nested in its master object. So how does this parameter work?

Thank you.

Hi Seya,
We have not reproduced such behavior, nested related objects are fetched correctly.
Please try fetching your tables using REST console to avoid any possible errors while using JS SDK.

Thanks for the answer. What do you mean by “use a rest console”? Is it an external tool? Is there a way to integrate it to my code? My goal is to fetch data which will then be consumed by other services in my application

REST console is part of Backendless Console interface. Go to Data -> <Table> -> Rest console and run your query

Thank. I’ll have to review my code.