Nearby Restaurant like UberEats and Zomato

Hey, I am trying to get the restaurants that comes inside the user’s co-ordinate.
Each of the restaurants has its own co-ordinate with a varying delivery radius.

I am new to mongodb but i know i dont need the $nearBy query, as it requires the max-distance parameter. So we will have only user’s co-ordinate supplied to the query and query will try to see which of the restaurants are qualified for the user’s co-ordinate according to restaurant’s delivery radius.

Reference Image:

Thanks in advance

Hi @Gulzar_Ahmed,

Welcome to MongoDB community!

You should use a $near or a $geoNear aggregation parameter . The maxDistance parameters are optional.

So you will place user coordinate from user object and query the restaurants with either a set or unset maxDistance radius.

See examples.