QueryStreamData
Description
You can use this service to query the stream entries based on the specified input parameters. The query and filter is similar to QueryStreamEntriesWithData; however, the resulting infotable contains only the time stamp and fields defined in the Data Shape associated with the stream.
Inputs
Parameter Name
Description
Base Type
maxItems
Maximum number of items to return in the result set. The default value is 500. This parameter is applied after all other filters are applied.
NUMBER
source
The source for the stream entry. When the stream entry was created, a valid source_type should have been selected. This source can have model tags associated with it.
STRING
tags
The Data tags associated with the stream entry.
TAGS
sourceTags
The Model tags associated with the source of this entry.
TAGS
startDate
The timestamp after which the stream entry was created.
DATETIME
endDate
The timestamp before which the stream entry was created.
DATETIME
oldestFirst
Retrieve from the oldest or newest records. The default value is false.
BOOLEAN
query
The query criteria to filter data.
For more information, seeQuery Parameter for Query Services.
QUERY
Output
Parameter Name
Description
Base Type
result
Returns an infotable that contains the timestamp and fields defined in the Data Shape associated with the stream.
INFOTABLE
Example
In the following example, TestStream has a Data Shape that has Property1, Property2 and Property3 fields.
Entity
ModelTags
Administrator
System
Thing1
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm1"}
entry_id
source
source_type
location
DataTags
Property1
Property2
Property3
1
System
User
1
2
3
2
Administrator
User
a
b
c
3
Thing1
Thing
{vocabulary: "DataTag1", vocabularyTerm: "DT1-Term1"}
1
2
3
4
AAA
Unknown
aa
bb
cc
5
Thing1
Thing
{vocabulary: "DataTag1", vocabularyTerm: "DT1-Term1"}
1
2
3
The following example shows a query for stream entries using all supported parameters. This API call returns an infotable that contains timestamp, Property1, Property2, and Property3:
result = Things["TestStream"].QueryStreamData({
maxItems: 50,
source: 'Thing1',
tags: "DataTag1:DT1-Term1", /* Data tags on Stream Entry */
sourceTags: "MT1:MT1-MTerm1", /* Model tags on Source entity */
startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
endDate: Date.now(),
oldestFirst: false,
query: "{ \"sorts\": [{\"fieldName\": \"Property1\"}]}"
});
Was this helpful?