Joining multiple tables in a single call

rest

#1

Hi, For example I have three tables.

Users
userid, name, contactid

Contacts
contactid, contact

Operators
operatorid, operator, contactid

The relation is like

Each User can have mulitple Contacts, and each Contacts can have multiple Operators, so the result data should look like below

{
  "resource": [
    {
      "userid": 1,
      "name": "User1",
      "contacts_by_userid": [
        {
          "contactid": 1,
          "contactno": "8888888888",
          "userid": 1,
          "operators_by_contactid": [
            {
              "operatorid": 1,
              "operatorname": "O2"
            },
            {
              "operatorid": 2,
              "operatorname": "Vodafone"
            }
          ]
        }
      ]
    }
  ]
} 

As you can see in the above data, this is what I want to get, I have added a Virtual Relation in Users table name contacts_by_userid to map Contacts to it, it works fine, but I am not getting how to fetch inter-related data for Operators virtual relation ie operators_by_contactid which I have added in Contacts table in a single call.

Thanks.