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
$findInCollectionsfilter 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
| Field | Type | Required | Description |
|---|---|---|---|
filter | Boolean | Required | Set to true to filter only telemetry items that match the readings query |
includeResult | Boolean | Optional | Set to true to include the reading data in the response |
query | Object | Required | Use to add your query object |
options | Object | Optional | Apply simple query options such as page, sort, and project |
options.project | Object | Optional | Simple query projection to enable or disable telemetry item fields in the response |
options.page | Object | Optional | Set the _pageSize and _offset for a page. The default for _pageSize is 200 and for _offset is 0. |
options.sort | Object | Optional | Simple query sort to sort your results by telemetry item fields |
as | String | Required | Enter 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" } }