Company
Date Published
Author
MongoDB
Word count
1563
Language
English
Hacker News points
None

Summary

The Weather of the Century app uses MongoDB to display weather data from 1901 onwards anywhere on Earth for any hour. The app's schema stores weather observations as single documents in a collection, with fields such as position, elevation, air temperature, and atmospheric pressure. The app uses two queries: one to retrieve all temperature data available everywhere in the world at one time, and another to find the weather data from the station closest to the specified location for a given hour. The first query uses an aggregation pipeline to group documents by station and select the first measurement per hour, while the second query uses the $near geospatial query operator to find the document with the closest position to the user's location.