Skip to content
Developerhome

Simple query: Read

  Less than to read

You need to use the _id reference key to read data.

If there is a natural key, the numeric key can be replaced by # followed by the natural key. However, the indicated key remains _id.

A natural key can have two or more components.

The following table shows two queries that return the same result.

{ 
    xtremMasterData { 
        customer { 
            read(_id: "6") { 
                _id 
                name 
                id 
                isOnHold 
                currency { 
                    id 
                    name 
                } 
            }
        } 
    } 
} 
{
    "data": { 
        "xtremMasterData": { 
            "customer": { 
                "read": { 
                    "_id": "6", 
                    "name": "DISTRITECH", 
                    "id": "FR001", 
                    "isOnHold": false, 
                    "currency": { 
                        "id": "EUR", 
                        "name": "Euro" 
                    } 
                } 
            } 
        } 
    }, 
    "extensions": { 
        "diagnoses": [] 
    } 
} 
{ 
    xtremMasterData { 
        customer { 
            read(_id: "#FR001") { 
                _id 
                name 
                id 
                isOnHold 
                currency { 
                    id 
                    name 
                } 
            } 
        } 
    }
}

You can read properties from the main node, but also from all the properties found in records that are referenced at any level. For this example, these are the properties associated with each currency.

The access method using the _id value or the natural key value works for nodes that have natural keys defined. However, not all nodes have natural keys. In this case, you can either:

  • Use a query with a filtering condition on the document number
  • Read with the _id value

A two-part key is a key composed of two natural keys.

A two-part key has the following structure: #key1|key2.

The following table displays the differences in the read operation between the use of the _id value and use of a two-part key:

</table>
{
  xtremMasterData {
    itemAllergen {
      read(_id: "142") {
        item {
          id
        }
        _sortValue
        allergen {
          id
        }
      }
    }
  }
}
{
  "data": {
    "xtremMasterData": {
      "itemAllergen": {
        "read": {
          "item": {
            "id": "EGGS"
          },
          "_sortValue": 10,
          "allergen": {
            "id": "EGG"
          }
        }
      }
    }
  },
  "extensions": {
    "diagnoses": []
  }
}
{
  xtremMasterData {
    itemAllergen {
      read(_id: "#EGGS|10") {
        item {
          id
        }
        _sortValue
        allergen {
          id
        }
      }
    }
  }
}
{
  "data": {
    "xtremMasterData": {
      "itemAllergen": {
        "read": {
          "item": {
            "id": "EGGS"
          },
          "_sortValue": 10,
          "allergen": {
            "id": "EGG"
          }
        }
      }
    }  },
  "extensions": {
    "diagnoses": []
  }
}