Custom queries
By using custom query params we can manipulate our HTTPS responses. Much like NoSQL operations as seen in MongoDB for example.
On this page we add new operators and update existing ones if necessary.
Custom queries can be chained, so these two are doing the same thing:
&__only=country,city
And
&__only=country
&__only=city
Query by name
Simplest querying is by propery name and property value.
Format:
&propName=propValue
This query is case sensitive.
Usage:
curl https://api.nodb.sh/my-app/dev/objects?token=1234567abcdefg&color=Red&age=12
This will match only records containing the following key-value pairs:
{
"color": "Red",
"age": 12,
...
}
__only
This query param allows us to return only some props from the entity.
Format:
&__only=propName1,propName2,...propNameN
# Or
&__only=propName1
&__only=propName2...
Usage:
curl https://api.nodb.sh/my-app/dev/objects?token=1234567abcdefg&__only=age,subspecies
Result:
[
{
"id": "...",
"age": 105,
"subspecies": "Aldabra",
"..." # the rest won't be present in the result
}
]
__includes
Returns only items which include all values specified in the '__includes' query separated by comma. It is meant for properties with array type.
Format:
&__includes=propName:Value1,Value2,...ValueN
# Or
&__includes=propName:Value1
&__includes=propName:Value2...
Usage:
curl https://api.nodb.sh/my-app/dev/teams?token=1234567abcdefg&__includes=members:John Doe,Jane Doe
It will work for array properties matching all values:
{
"members": ["John Doe", "Jane Doe"]
}
__includes_any
Returns items which include any value specified in the '__includes_any' query separated by comma. It is meant for properties with array type.
Format:
&__includes_any=propName:Value1,Value2,...ValueN
# Or
&__includes_any=propName:Value1
&__includes_any=propName:Value2...
Usage:
curl https://api.nodb.sh/my-app/dev/teams?token=1234567abcdefg&__includes_any=members:John Doe,Jane Doe
It will work for array properties matching at least one value provided in the query:
{
"members": ["John Doe", "Bob Smith"]
}
__like
This query searches for entities which contain part of the string as its value. For example for a value "Earth" you can search by "arth".
Format:
&__like=propName1:stringValue1
&__like=propName2:stringValue2...
Usage:
curl https://api.nodb.sh/my-app/dev/planets?token=1234567abcdefg&__like=name:arth
__sort_by
You can sort your data by one or more property names.
Format:
&__sort_by=propName1,propName2,...propNameN
# Or
&__sort_by=propName1
&__sort_by=propName2...
Usage:
curl https://api.nodb.sh/my-app/dev/articles?token=1234567abcdefg&__sort_by=issueDate,readingTime
__sort_by_desc
Same as __sort_by
only reversed.
__no_meta
Trim all __meta
props from query results, including the pagination.
! ("not" operator)
Opposite of querying by name. Add the !
in front of prop name to negate it.
Format:
&propName=!propValue
This query is case sensitive.
Usage:
curl https://api.nodb.sh/my-app/dev/objects?token=1234567abcdefg&color=!Red