你可以帮我解决这个问题,我尝试使用namaKota(城市名称)和Lat,Long参数搜索附近的位置。这是我的代码
var namaKota = "Malang";
var coords = [];
coords[0] =lat;
coords[1] =long;
VehiclesDB.aggregate([
{
$geoNear: {
geoNear: "rentaldbs",
near: coords,
}
},
{
$lookup:
{
from: "rentaldbs",
localField: "mitraId",
foreignField: "_id",
as: "mitra"
}}
,
{
$unwind: "$mitra"
},{
$match: {
"mitra.namaKota": namaKota
}
}
和我的结果一样
Couldn't find any Vehicles with idMalang