1

我正在尝试geoNear查询,我在没有mongodb的查询中添加了额外的查询。paramsgeoNearlat,long

例子:

searchQuery = [
  { "postLocationType": { $exists: true } }, 
  { "languageType": mongoose.Types.ObjectId(body.languageType) }, 
  { typeId }, 
  { subTypeId }, 
  { "discountExpires": 
  { $gte: new Date() } }];
$geoNear: {
   near: { type: "Point", coordinates: [long, lat] },
   distanceField: "dist.calculated",
   maxDistance: searchUnit === config.SEARCH_UNIT_KM ? maxKms : maxMiles,
   query: { $and: searchQuery }, //condition for checking postTitle,typeId and post should not be exired.
   spherical: true,
   distanceMultiplier: searchUnit === config.SEARCH_UNIT_KM ? distanceInKm : distanceInMiles
   } 
4

0 回答 0