When you Query Records in a Table, you can specify a filter
object in the body of the request. This way, you can narrow down the Records to retrieve from a Table to meet your needs.
For example, to find all the employees who are based in the Central Regional Office, you can define the filter
in body parameter of the request below:
curl --request POST "https://42d54rt5-d389-845a-6lkq-34z563gtu872.api.morphdb.io/v0/record/dw5g1h89-2637-253k-452b-7803j4x7e3vi/employee_csv_demo/query" \
--header "Content-Type: application/json" \
--header "client-type: widget" \
--header "x-api-key: ms5sCDEOVNuIw92MNA3qLKih4xzY25D9PQY6D7Az2" \
--data '{
"select":["*"],
"filter":{
"and":[
{
"key":"regional_office",
"operator":"equal",
"value":"Central"
}
]
},
"sort":[],
"limit":50,
"skip":0
}'
Multiple filters can be applied to narrow down even further your query.
There is no limit to the nesting of filters!
For example, find all the employees who are based in the Central Regional Office, or whom managers have an ID of 10038 or 10039.
curl --request POST "https://42d54rt5-d389-845a-6lkq-34z563gtu872.api.morphdb.io/v0/record/dw5g1h89-2637-253k-452b-7803j4x7e3vi/employee_csv_demo/query" \
--header "Content-Type: application/json" \
--header "client-type: widget" \
--header "x-api-key: ms5sCDEOVNuIw92MNA3qLKih4xzY25D9PQY6D7Az2" \
--data '{
"select":["*"],
"filter":{
"or":[
{
"key":"regional_office",
"operator":"equal",
"value":"Central"
},
{
"key":"mgr_id",
"operator":"equal",
"value":10038
},
{
"key":"mgr_id",
"operator":"equal",
"value":"10039"
}
]
},
"sort":[],
"limit":50,
"skip":0
}'
If you provide no filter, all the Records in the Table will be returned based on any of the other criteria you might define (sort, limit, etc.).
For example, it is the case of the body of the request in the Quickstart.
{
"select":["*"],
"sort":[],
"limit":5,
"skip":0
}
QueryRecordsRequestBodyObject
Properties and types
Key | Type | Description |
---|---|---|
select | array of string | |
join | array of RecordConditionRuleUnit objects. | |
filter | either one of: - RecordFilterConditionAnd objects. - RecordFilterConditionOr objects. | |
format | array of any of: - RecordFilterConditionAnd objects. - RecordFilterConditionOr objects. | |
sort | array of RecordSortConditionUnit objects. | |
limit | number | |
skip | number |
JSON representation
{
"select": [
"string"
],
"join": [
{
"targetTable": "string",
"rules": [
{
"tableKey": "string",
"targetTableKey": "string"
}
]
}
],
"filter": {
"and": [
{}
]
},
"sort": [
{
"key": "string",
"direction": "ascending"
}
],
"limit": 0,
"skip": 0,
"addtionalFilter": {
"and": [
{}
]
},
"additionalSort": [
{
"key": "string",
"direction": "ascending"
}
]
}
RecordConditionRuleUnit object
Properties and types
Key | Type | Description |
---|---|---|
targetTable | string | |
rules | array of RecordJoinRuleUnit objects. |
JSON representation
{
"targetTable": "string",
"rules": [
{
"tableKey": "string",
"targetTableKey": "string"
}
]
}
RecordJoinRuleUnit object
Properties and types
Key | Type | Description |
---|---|---|
tableKey | string | |
targetTableKey | string |
JSON representation
{
"tableKey": "string",
"targetTableKey": "string"
}
RecordFilterConditionAnd object
Properties and types
Key | Type | Description |
---|---|---|
and | array of any of: - RecordFilterConditionAnd object - RecordFilterConditionUnit object - RecordFilterConditionOr object | An array of any of the filter objects:RecordFilterConditionAnd ,RecordFilterConditionUnit ,RecordFilterConditionOr .Returns Records which match the filter conditions. |
JSON representation
{
"and": [
{}
]
}
RecordFilterConditionOr object
Properties and types
Key | Type | Description |
---|---|---|
or | array of any of: - RecordFilterConditionAnd object - RecordFilterConditionUnit object - RecordFilterConditionOr object | An array of any of the filter objects:RecordFilterConditionAnd ,RecordFilterConditionUnit ,RecordFilterConditionOr .Returns Records which match the filter conditions. |
JSON representation
{
"or": [
{}
]
}
RecordFilterConditionUnit object
Properties and types
Key | Type | Description |
---|---|---|
key | string | |
operator | string | allowed values: - equal - notEqual - lessThan - lessThanOrEqual - greaterThan - greaterThanOrEqual - isNull - notNull - like - startsWith - endsWith - in - notIn |
value | either of the following types: - string , or- number , or- boolean , or- null , or- array of string or number or boolean . | operator in and notIn take array of values |
isFixed | boolean |
JSON representation
{
"key": "string",
"operator": "equal",
"value": "string",
"isFixed": true
}