M121 Chapter 2 Utility Stages: $geoNear limit parameter not available

Hello,

A correction note must be added in the Lecture Notes of the video to state that $geoNear no longer supports the ‘limit’ parameter and that a $limit stage instead must be used:

The correct aggregation is as follows:

db.nycFacilities.aggregate([{$geoNear:
                         {near:{type:"Point", coordinates:[-73.98769766092299, 40.757345233626594]},
                         distanceField:"distanceFromMongoDB",
                         spherical:true, query:{type: "Hospital"}}
                        },{ $limit: 5}])

Jaime H Rozo :space_invader: :coconut:

2 Likes
  • Always make it pretty :slight_smile:
    .pretty()
2 Likes