Hierarchy

  • QueriesUtil

Constructors

Methods

  • Builds query string from provided query object.

    Returns

    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)
    };

    Parameters

    • query: any

      Object containing filters and sort order for querying managed objects. Supported filters are:

      • __and - Specifies conditions, e.g. {__and: [{__has: 'c8y_IsDevice'}, {'count': {__gt: 0}}]}.
      • __or - Specifies alternative conditions, e.g. {__or: [{__bygroupid: 10300}, {__bygroupid: 10400}]}.
      • __eq - Specified fragment must be equal to given value, e.g. {'status': 'AVAILABLE'} (no nested object required).
      • __lt - Specified fragment must be less then given value, e.g. {'count': {__lt: 10}}.
      • __gt - Specified fragment must be greater then given value, e.g. {'count': {__gt: 0}}.
      • __in - Specified fragment must be equal to one of values in the list, e.g. {'status': {__in: ['AVAILABLE', 'UNAVAILABLE']}}.
      • __not - Negates condition, e.g. {__not: {'status': 'AVAILABLE'}}.
      • __bygroupid - True if filtered managed object is assigned to given group, e.g. {__bygroupid: 10300}.
      • __has - Specified fragment must have a value defined, e.g. {__has: 'c8y_IsDevice'}.
      • __useFilterQueryString - Gets rid of the $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.

      The order is specified by an array of field paths and sort direction (1 for ascending, -1 for descending), e.g.:

      • {__orderby: [{'creationTime': -1}, {'name': 1}], __filter: {...}}

    Returns string

  • Parameters

    • queryFilter: any
    • Optional _queryKey: any
    • Optional _glueType: any

    Returns string