Show
Destroy
An entry
Get it down. Make it good. Share it.
Title
Text
``` db.earthquakes.aggregate( [ { $project : { month_joined : { $month : "$joined" } } } , { $group : { _id : {month_joined:"$month_joined"} , number : { $sum : 1 } } }, { $sort : { "_id.month_joined" : 1 } } ] ) { $project : { month_joined : "$time" } }, db.earthquakes.aggregate( [ { $project : { danger_score : "$time" } }, { $group : { _id : { danger_score: "$danger_score" } , number : { $sum : 1 } } }, { $sort : { "_id.month_joined" : 1 } } ] ) score = $geoNear: { near: [40.724, -73.997], distanceField: "dist.calculated", maxDistance: 0.008, query: { type: "public" }, includeLocs: "dist.location", uniqueDocs: true, num: 5 } // example db.collection.aggregate ( [ {$group : {_id : "$product", count : {$sum:"$cCount"}, cpids : {$push : "$cpid"} } }, {$unwind : "$cpids"}, {$group : {_id : "$_id", cCount : {$first:"$count"}, cpid : {$addToSet : "$cpids"} } } ] ) db.earthquakes.aggregate([ { $geoNear: { near: [-64.0, 19.0], distanceField: 'dist_calculated', spherical: true, maxDistance: 25 / 3569 } } ]) // Step 1 db.earthquakes.aggregate( [ { $geoNear: { near: [-122, 37], distanceField: "dist_calculated", spherical: true, maxDistance: 50.0 / 3959.0, } } ] ) db.earthquakes.find().limit(10).forEach(function(quake){ quakes = db.runCommand({ geoNear: "earthquakes", maxDistance: 25 / 3969, near: quake.coordinates, spherical: true, limit: 5000 }); z = db.earthquakes.aggregate( [ { $geoNear: { near: quake.coordinates, distanceField: "dist.calculated", spherical: true, maxDistance: 50.0 / 3959.0, } }, { $group: { _id: "", total: { $sum: "$mag" }, count: { $sum: 1 } } } ] ); printjson(quake.uid, z) }); db.earthquakes.aggregate( [ { $geoNear: { near: quake.coordinates, distanceField: "dist.calculated", spherical: true, maxDistance: 50.0 / 3959.0, } }, { $group: { _id: "", total: { $sum: "$mag" }, count: { $sum: 1 } } } ] ); db.earthquakes.aggregate( [ { $geoNear: { near: [-122, 37], distanceField: "dist.calculated", spherical: true, maxDistance: 50.0 / 3959.0, } }, { $group: { _id: "", total: { $sum: "$mag" }, count: { $sum: 1 } } } ] ) { $project : { danger_score: "$result.length()" } } { $group : { _id : { danger_score: "$danger_score" } , number : { $sum : 1 } } } db.earthquakes.aggregate( [ { $project: { danger_score: { $geoNear: { near: [40.724, -73.997], distanceField: "dist.calculated", maxDistance: 0.008, query: { type: "public" }, includeLocs: "dist.location", uniqueDocs: true, num: 5 } } } }, { $group : { _id : { danger_score: "$danger_score" } , number : { $sum : 1 } } }, { $sort : { "_id.danger_score" : 1 } } ] ) $geoNear: { near: [40.724, -73.997], distanceField: "dist.calculated", maxDistance: 0.008, query: { type: "public" }, includeLocs: "dist.location", uniqueDocs: true, num: 5 } ```
Status
idea
draft
release
personal
Series
Part of a Series?
Bitcoin
On Work
Phoenix Trello Tutorial
Civics
Re Email Address
Tags
notes
×
mongodb
×
+
Slug
Url
Image 1
Image 2
Image 3
Visible
Date