Get Parent only if child is found

Hi,
I am trying to get node data if its child condition satisfies. Here is the query

{
  me(func: has(has_code)) {
  uid
  has_code @filter (eq(otcCode,"162159")){
    expand(_all_)
  }
  }
}
Result

{
  "extensions": {
    "server_latency": {
      "parsing_ns": 36100,
      "processing_ns": 54833100,
      "encoding_ns": 947000
    },
    "txn": {
      "start_ts": 110255
    }
  },
  "data": {
    "me": [
      {
        "uid": "0x4e2d",
        "has_code": [
          {
            "otcType": "register",
            "otcCode": "162159",
            "otcExpiry": "2019-05-31T15:56:37.326109+05:00",
            "otcCreatedDate": "2019-05-30T15:56:37.326109+05:00",
            "label": "otc"
          }
        ]
      },
      {
        "uid": "0x7531"
      }
    ]
  }
}

The second uid “uid”: “0x7531” should not be fetch because it does not satisfies the condition. Please solve the issue… How to now fetch data if the child does not satisfies the condition.

This node is about “has(has_code)
Try:

{
  me(func: has(has_code)) @cascade {
  uid
  has_code @filter (eq(otcCode,"162159")){
    expand(_all_)
  }
  }
}

More about it https://docs.dgraph.io/query-language/#cascade-directive

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.