ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / Big Data / Managing Mongo data files
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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"":  { ""name"": ""$biggestCity"",  ""pop"": ""$biggestPop"" },"+CR+...
"      ""smallestCity"": { ""name"": ""$smallestCity"", ""pop"": ""$smallestPop"" }"+CR+...
"    }"+CR+...
"  }"+CR+...
"]"


let r = MongoAggregationPipeline(gCnx.BaseDeDonnées["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: 09/21/2024

Send a report | Local help