MongoCollectionAggregate[MongoCollection[…],pipeline]
calculates aggregate values for the data in a MongoCollection.
MongoCollectionAggregate
MongoCollectionAggregate[MongoCollection[…],pipeline]
calculates aggregate values for the data in a MongoCollection.
Details and Options
- To use MongoCollectionAggregate, you first need to load MongoLink using Needs["MongoLink`"].
- pipeline is a list of associations. The available aggregation pipeline operators can be found in the MongoDB documentation.
- More information about the aggregation pipeline can be found in the MongoDB documentation.
- MongoCollectionAggregate corresponds to db.collection.aggregate() in the MongoDB documentation.
Examples
Basic Examples (1)
Needs["MongoLink`"]client = MongoConnect[]Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:
coll = client["WolframTestDB"]["WolframTestCollection"]Aggregate values for count and average, grouped by sex:
agg = MongoCollectionAggregate[coll, {<|"$group" -> <|"_id" -> <|"sex" -> "$sex"|>, "count" -> <|"$sum" -> 1|>, "average" -> <|"$avg" -> "$age"|>|>|>}]Dataset[agg]See Also
Tech Notes
Related Guides
Text
Wolfram Research (2018), MongoCollectionAggregate, Wolfram Language function, https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionAggregate.html.
CMS
Wolfram Language. 2018. "MongoCollectionAggregate." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionAggregate.html.
APA
Wolfram Language. (2018). MongoCollectionAggregate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionAggregate.html
BibTeX
@misc{reference.wolfram_2026_mongocollectionaggregate, author="Wolfram Research", title="{MongoCollectionAggregate}", year="2018", howpublished="\url{https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionAggregate.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_mongocollectionaggregate, organization={Wolfram Research}, title={MongoCollectionAggregate}, year={2018}, url={https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionAggregate.html}, note=[Accessed: 12-June-2026]}