Include reference object



  • Imagine we have 2 object types: TypeA and TypeB.
    TypeA has a property that is a ref to an object of TypeB.
    @{
    //other properties
    "typeBRef":{
    "id":"OBJECT_ID",
    "objectType":"objects.TypeB"
    }
    }@

    Is there a way to get nested object data of TypeB if we have only ID of an object of TypeA(with only one request)?
    Maybe using INCLUDE parameter?

    Currently if we request an object of TypeA we get the object I mentioned above in typeBRef property, but I need data of that object (it is like JOIN in SQL).

    P.S. I can do that using 2 requests, first for TypeA object and the second for TypeB object using ID received from the previous reply, but I want to get it using only one request.

    Thanks in advance.


  • cid:52:privileges:purge

    It's possible include nested object data using "include" parameter: https://engin.io/documentation/rest/parameters/include

    In this case include parameter would be something like:
    @
    {"typeBRef": {}}
    @

    (value can be blank object because enginio already knows how to include ref-properties)



  • Thanks! Works with the "query" function perfect. I tried it with "search" before and it didn't work.



  • Can we create objects using INCLUDE parameter? I mean via one request to the server.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.