{"version":"1.0","type":"rich","title":"MapReduce with MongoDB in NodeJS","description":"This example demonstrates a MapReduce operation in MongoDB, executed from a Node.js application, that aggregates sensor measurements into hourly averages per user and device. The code defines custom `map`, `reduce`, and `finalize` functions to group raw data points by a composite key of user email, device UID, and the hour timestamp, then computes a weighted average value and total weight. The operation queries MongoDB’s `Measure` collection, merges results into an output collection named `measure1hs`, and reports execution statistics via a callback. The implementation uses MongoDB’s native `db.Measure.collection.mapReduce` API directly, bypassing Mongoose, and handles asynchronous completion through a callback function.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-e6045b4c4e0196aa526b07fc7ef9c949?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}