pipelinequery argument with the request. The pipeline query argument is an array of pipeline stages that execute in order. Each stage transforms the result set and passes it on to the next stage in the pipeline.
$matchstage. This filters the result set to all accounts create on or after
2015-01-01T00:00:00.000Z. Then that set of results is passed onto the
$groupstage which counts all of the accounts in the result set and finally returns a
countresult. For all available stages, see Pipeline Stages
_idproperty is your grouping expression and is required. The
_idcan be null, it can be a single property or a combination of properties and group expressions. When you specify an
null, you will group together all of the documents in the result set. This is helpful for calculating accumulated values for all of the documents, for example when calculating a cont of the total number of documents in your result. When the
_idis null, it is not included in the result set.
c_patientobject with a two-stage pipeline. The first stage is a
$matchthat filters the documents down to patients with a
gender: 'f'. Those documents are then passed into the
$groupstage where we count all of the documents in the result set and return a
countproperty. Because we pass
nullfor the grouping
_id, we can calculate an accumulation for the entire result set.
connectionsobject. The grouping is by the connections'
context._id. Then, a count is calculated for each context grouping and returned in
$matchstage accepts a JSON document that specifies query conditions on indexed properties to filter the resulting document list. This document list is then passed onto the next stage of the pipeline or returned as the response if it is the last stage of the pipeline.
_id, only properties that you specify for inclusion or add to the projection as new properties will be projected on to the next stage.
_idproperty is always included in the projection, even if you don't specify inclusion.
c_patientobject is aggregated with a two stage pipeline in a script. The first stage is a
$matchthat finds all patient records with
c_gender: 'm'. That result set is then passed into the
$projectstage. The projection then specifies that
c_genderproperties are included and that
ageare added as new properties.
fullNameproperty is a concatenation of the
c_lastsub-properties if the
c_namedocument property using the
$concatstring operator and
ageproperty is calculated from an existing
$floorarithmetic operators to calculate the age from the difference between
c_birthdateand today's date.
$projectstage is the last stage in the pipeline, the result of the projection is returned as the response.
1for ascending or
$sortat the beginning of the pipeline or near the beginning, after a
$sortshould always proceed
$groupif it is required -- otherwise your query may be slow or time out.