Skip to main content
Version: v5.1

readings query

readings query#

Use a readings query object in your related query to search related collections and query their readings’ timeseries collections.

The following isolated and empty readings code example displays the structure and the properties in a readings object:

Note: For more information on adding a readings query to your $findInCollections filter in a real worldexample, see readings query in a findInCollections query.

"readings": {     "filter": true,      "includeResult": true,            "query": {                  //valid simple query object  },              "options": {            "project": {      "<telemetry item field to appear in the response>": 1    },            "page": {                          "_pageSize": "<page size value you want as an integer>",                      "_offset": "<page size value you want as an integer>"     },                "sort": {      "<property you want to sort by in the response>": 1    },  },              "as": "<field name for the telemetry item results in the response>"        }

readings query fields table

FieldTypeRequiredDescription
filterBooleanRequiredSet to true to filter only telemetry items that match the readings query
includeResultBooleanOptionalSet to true to include the reading data in the response
queryObjectRequiredUse to add your query object
optionsObjectOptionalApply simple query options such as page, sort, and project
options.projectObjectOptionalSimple query projection to enable or disable telemetry item fields in the response
options.pageObjectOptionalSet the _pageSize and _offset for a page. The default for _pageSize is 200 and for _offset is 0.
options.sortObjectOptionalSimple query sort to sort your results by telemetry item fields
asStringRequiredEnter a name for the field that contains the readings in the response

The following code example is a typical readings query. In the example, the query matches readings with temperature values greater than or equal to 11℃ and a timestamp value on or after 09:00 on December 1st, 2021:


"readings": {  "filter": true,  "includeResult": true,  "query": {    "$and": [      {        "temp": {          "$gte": 11        }      },      {        "_ts": {          "$gte": "2021-12-01T09:00:00.000Z"        }      }    ]    },    "options": {      "page": {        "_pageSize": 100,        "_offset": 0      }    },    "as": "temperature_sensors"  }  }