Company
Date Published
Author
Tim Fogarty
Word count
986
Language
English
Hacker News points
None

Summary

The MongoDB World Weekly Challenges were a series of developer challenges designed to test skills in using the MongoDB platform. One of the early challenges was the Aggregation Rock Star Challenge, which required developers to write an aggregation pipeline to calculate the average mass and standard deviation for meteorites within 1000km of McMurdo Antarctic Research Station for each decade from 1970 to 2019. The challenge used a geospatial index to filter meteorite records and then grouped them by decade using the $bucket stage, calculated the average and standard deviation of the mass using the $stdDevPop aggregation operator, and finally presented the results in a single document. The solution involved multiple stages, including $geoNear for filtering, $addFields for converting dates to years, $match for filtering out records before 1970, $bucket for grouping by decade, $group for aggregating the results, and $project for presenting the final output. Common mistakes included formatting errors, incorrect calculation of averages or standard deviations, and failure to use the correct aggregation operators.