ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / Big Data / Managing Mongo files
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
MongoAggregationPipeline (Function)
In french: MongoPipelineAgrégation
Used to retrieve documents that enter a multi-stage pipeline and are transformed into aggregated results.
Example
sPipeline is string = ...
"["+CR+...
"  { ""$group"":"+CR+...
"    {"+CR+...
"      ""_id"": { ""state"": ""$state"", ""city"": ""$city"" },"+CR+...
"      ""pop"": { ""$sum"": ""$pop"" }"+CR+...
"    }"+CR+...
"  },"+CR+...
"  { ""$sort"": { ""pop"": 1 } },"+CR+...
"  { ""$group"":"+CR+...
"    {"+CR+...
"      ""_id"": ""$_id.state"","+CR+...
"      ""biggestCity"":  { ""$last"": ""$_id.city"" },"+CR+...
"      ""biggestPop"":   { ""$last"": ""$pop"" },"+CR+...
"      ""smallestCity"": {""$first"": ""$_id.city"" },"+CR+...
"      ""smallestPop"":  {""$first"": ""$pop"" }"+CR+...
"    }"+CR+...
"  },"+CR+...
"  { ""$project"":"+CR+...
"    {"+CR+...
"      ""_id"": 0,"+CR+...
"      ""state"": ""$_id"","+CR+...
"      ""biggestCity"":  {""nom"": ""$biggestCity"",  ""pop"": ""$biggestPop"" },"+CR+...
"      ""smallestCity"": {""nom"": ""$smallestCity"", ""pop"": ""$smallestPop"" }"+CR+...
"    }"+CR+...
"  }"+CR+...
"]"
 
 
let r = MongoAggregationPipeline(gCnt.Database["db"].Collection["zipcodes"], sPipeline)
FOR EACH v OF r
Trace(VariantToJSON(v))
END
Syntax
<Result> = MongoAggregationPipeline(<Collection> , <Pipeline>)
<Result>: mongoResult variable
mongoResult variable corresponding to the result. If a problem occurs, ErrorInfo is used to identify the error.
<Collection>: mongoCollection variable
Name of the mongoCollection variable corresponding to the MongoDB collection where the document search will be performed.
<Pipeline>: Character string
json(string), bson(buffer) or variant document that describes the pipeline in mongoDB format.
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help