Date: Fri, 29 Mar 2024 10:36:09 +0000 (UTC) Message-ID: <2140972469.1241.1711708569016@a76c2b730791> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1240_2059778937.1711708569016" ------=_Part_1240_2059778937.1711708569016 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Engine Compatibility
The query()
operator is not supported by=
the new pico engine.
The query()
operator can be used to search structured persi=
stent variables. The syntax is
&= lt;persistent variable>.query(<hash path>, { 'requires' : <join operator>, 'conditions : [ { 'search_key' : <path_to_field>, 'operator' : <mongo $ comparison op>, 'value' : <value> }, ... ] },| <extended result> );
[]
, if the=
key is at root.
search_key
is the path from the <hash=
path>
to the field that you want to compare. If that path =
does not exist for an entry, it will not be considered even as a null=
For example to do a twitter timeline search where the entri= es have been assigned a unique key to transform the array into a hash:
e= nt:tweets.query([],{ 'requires' : '$and',=20 'conditions' : [ { 'search_key' : ['retweeted_status', 'favorite_count'], 'operator' : '$gt', 'value' : 5 }, { 'search_key' : ['retweeted_status', 'favorite_count'], 'operator' : '$lt', 'value' : 200 } ]})
This= will return an array of <hash paths> (array of arrays) that is essen= tially an array of the keys to the matching values
[ [ 'a32' ], [ 'a31' ], [ 'a30' ] ]
You =
can then use the values to get the entire element with ent:tweets<=
/span>
=
{[ 'a32' ]}.
if the third argument to query()
is not =
null, the actual result, rather than a path to it will be returned. =
p>
The following function from Fuse uses query()
=
to return trips by their end date, given a start and end date.
t= rips =3D function(start, end){ utc_start =3D common:convertToUTC(start); utc_end =3D common:convertToUTC(end); =20 ent:trip_summaries.query([], {=20 'requires' : '$and', 'conditions' : [ {=20 =09 'search_key' : [ 'endWaypoint', 'timestamp'], =09 'operator' : '$gte', =09 'value' : utc_start=20 =09 }, =09 { =09 'search_key' : [ 'endWaypoint', 'timestamp' ], =09 'operator' : '$lte', =09 'value' : utc_end=20 =09 } =09 ]}, =09"return_values" ) };
Note that KRL stores data in persistent variables in a "fla= t format" and therefore, all comparisons are string or numeric comparisons.= The query() operator doesn't know about dateTime and other special formats= for values.