Object containing filters and sort order for querying managed objects. Supported filters are:
{__and: [{__has: 'c8y_IsDevice'}, {'count': {__gt: 0}}]}
.{__or: [{__bygroupid: 10300}, {__bygroupid: 10400}]}
.{'status': 'AVAILABLE'}
(no nested object required).{'count': {__lt: 10}}
.{'count': {__gt: 0}}
.{'status': {__in: ['AVAILABLE', 'UNAVAILABLE']}}
.{__not: {'status': 'AVAILABLE'}}
.{__bygroupid: 10300}
.{__has: 'c8y_IsDevice'}
.$filter=()… $orderby=…
parts of a query and keeps only what's between the most
exterior parentheses of the $filter.
EXAMPLE: takes a query of the form
$filter=(name eq 'RaspPi*') $orderby=name asc
and turns it into
name eq 'RaspPi*'
This is necessary for searching for smart groups, which are identified by their own query
that needs to be passed through.Note: if you want to specify the order, you need to wrap your filters within __filter
property and then add __orderby
with the array of field paths and sort directions (1 for ascending, -1 for descending), for example:
{ __filter: { ... }, __orderby: [{ 'creationTime': -1 }, { 'name': 1 }] }
Returns a query string ready to be sent in request params to backend.
Example
const query = {
__filter: {
'name': 'My Device*',
'c8y_Availability.status': {
__in: ['AVAILABLE', 'UNAVAILABLE']
},
'creationTime': {
__lt: '2015-11-30T13:28:123Z'
},
'c8y_ActiveAlarmsStatus.critical': {
__gt: 0
},
__or: [
{__not: {__has: 'c8y_ActiveAlarmsStatus.major'}},
{
__or: [
{__bygroupid: 10300},
{__bygroupid: 10400}
]
}
]
},
__orderby: [
{'name': 1},
{'creationTime': -1},
{'c8y_ActiveAlarmsStatus.critical': -1}
]
};
const params = {
query: queriesUtil.buildQuery(query)
};
Builds query string from provided query object.