This method will query items based on URL parameters appended to the request. This method uses the S3 Select API, allowing for SQL-like queries on your data within NotoDB sets.
Example syntax for the query endpoint.
A query for a first name of `Velma` on a set that contains a list of users might look something like following:
[
{
"id": 20,
"first_name": "Velma",
"last_name": "Omand",
"email": "vomandj@creativecommons.org",
"ip_address": "188.130.239.149",
"job_title": "Administrative Assistant III",
"_id": "obhxfii36ldhscoc",
"_createdAt": 1652325906197,
"_updatedAt": 1652325906197
}
]
The above example uses exact matching on the `first_name` field. However, we can also use operators to compare field values with our query parameter. Here's an example where we are looking for anyone with a first name that contains `ma` in it:
[
{
"id": 80,
"first_name": "Salvador",
"last_name": "Zanardii",
"email": "szanardii27@go.com",
"ip_address": "123.140.133.176",
"job_title": "Analyst 3 Programmer",
"_id": "zu9qj80xilt62myr",
"_createdAt": 1652325906198,
"_updatedAt": 1652569393790
},
{
"id": 81,
"first_name": "Ina",
"last_name": "Lethardy",
"email": "ilethardy28@weather.com",
"ip_address": "188.169.111.212",
"job_title": "Graphic Designer",
"_id": "csl1azypsz2wxr99",
"_createdAt": 1652325906198,
"_updatedAt": 1652325906198
},
{
"id": 82,
"first_name": "Mathe",
"last_name": "Brazer",
"email": "mbrazer29@tumblr.com",
"ip_address": "117.153.194.188",
"job_title": "Research Nurse",
"_id": "6p9xk8rhm478vfp8",
"_createdAt": 1652325906198,
"_updatedAt": 1652325906198
}
]
Query operators
Operator | Syntax |
---|---|
Equals | first_name=bob |
Like | first_name=like:bob |
Starts with | first_name=start:bob |
Ends with | first_name=end:bob |
Greater than | age=gt:30 |
Greater than or equal to | age=gte:30 |
Less than | age=lt:30 |
Less than or equal to | age=lte:30 |
Multiple query operators
You can chain together multiple query operators in a single request. Example:
[
{
"id": 20,
"first_name": "Jennifer",
"last_name": "Omand",
"email": "jomand@adobe.com",
"age": 32,
"job_title": "Software Engineer",
"_id": "obhxfii36grhscoc",
"_createdAt": 1652325906197,
"_updatedAt": 1652325906197
}
]
Converting types for comparison
NotoDB will not imply the type of values provided. A string is always a string and an integer (int) is always an integer. An item with type int age of 30 is not equivalent to item with type string age of "30". With NotoDB, you can convert an int to a string by enclosing your URL parameter value with double quotes. Example:
[
{
"id": 20,
"first_name": "Jennifer",
"last_name": "Omand",
"email": "jomand@adobe.com",
"age": "32",
"job_title": "Software Engineer",
"_id": "obhxfii36grhscoc",
"_createdAt": 1652325906197,
"_updatedAt": 1652325906197
}
]
While you can convert an int to a string, you can not currently convert a string to an int in your query.
Next articleAggregate functions