In the previous post, we have seen how to search for a phrase using ArcQL.
Now we will check how to search non-null data in a field using the arcql EXIST query
-
EXIST
query returns records that have non-null data in a given field. - Frame a query like this.
EXIST a
We will work with the same schema used earlier.
type arcqlObject {
str: String
int: Int
}
Let’s insert the data in the arcqlObject. Notice that the third object has null data in the int
field.
mutation {
upsert(
values: {
arcqlObject: [
{ str: "hypi", int: 1 }
{ str: "low code", int: 2 }
{ str: "easy to use backend" }
]
}
) {
id
}
}
#result
{
"data": {
"upsert": [
{
"id": "01FJGS5P4C2V0AZ9BGPV6BXGEG"
},
{
"id": "01FJGS5P4DBC3HVS5EESRD63ZY"
},
{
"id": "01FJGS5P4ECE8BSG10FVJ1865V"
}
]
}
}
Let’s retrieve records that have non-null data in the int
field of the arcqlObject.
{
find(type: arcqlObject, arcql: "EXIST int") {
edges {
node {
... on arcqlObject {
str
int
hypi {
id
}
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"str": "hypi",
"int": 1,
"hypi": {
"id": "01FJGS5P4C2V0AZ9BGPV6BXGEG"
}
},
"cursor": "01FJGS5P4C2V0AZ9BGPV6BXGEG"
},
{
"node": {
"str": "low code",
"int": 2,
"hypi": {
"id": "01FJGS5P4DBC3HVS5EESRD63ZY"
}
},
"cursor": "01FJGS5P4DBC3HVS5EESRD63ZY"
}
]
}
}
}
We got the records with non-null data in the int
field. The third record with the null data in the int
field was not retrieved.
Check the POSTMAN collection for the exist query
in different programming languages! Click </>
and choose the programming language of your choice.
Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!