Given user location : [latitude, longitude]
RatingSchema : { company_id : xxxxx, rating : 3.44}.
CompanySchema : {comapany_id : xxxxx, company_name : "hdhh", location : {type : "Point" , coordinates : [77.6666, 12.4333]}}
db.collection('ratings').aggregate([
{$group : {Id : "$company_id", Num_rating: {$sum : 1}}},
{$match : {Num_rating : {$gte : 3}}},
{
$lookup :{
from : "companies",
}
}
])
If we can use GeoNear operator, then It is very easy but we can’t use Geonear here.
Now , We have to send the information of those companies with distance which have at least 3 ratings.
Please tell me how can I do it ?