geoNear no longer supports the limit parr

I got this msg in Chapter 2: Basic Aggregation - Utility StagesgeoNear Stage
“$geoNear no longer supports the ‘limit’ parameter. Use a $limit stage instead.”
Is any example in V6.0 ?
Thanks,
Diam

Hi @Dumitru_Denisiuc,
This has been discussed earlier here:

All you need to do is specify the $limit stage after the $geoNear stage like this:

db.<collection-name>.aggregate([
  {
    $geoNear: <mention all the options as before apart from the limit option>
  },
  {
    $limit: <mention the number of documents>
  }
]).pretty()

If you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
MongoDB

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.