Monday, 10 April 2017

NodeJs : $nin array query in $geoNear in MongoDb doesn't work

I don't understand why my query doesn't work with MongoDb $geoNear ?

I checked this issue without success : mongodb geoNear command with filter

My environment :

  • NodeJs : V6.6.0
  • Mongoose : 4.8.6

this works

db.collection.geoNear(
  coords,
  {
  query : { status: "1" } }, // I have the good filtered results
  ...

I already tested

...
query : { _id: { $in: itemIds } }, //no error and empty result
query : { "_id": "5639ce8c01f7d527089d2a74" },  //no error and empty result
query : { "_id" : 'ObjectId("5649e9f35f0b360300cad022")' }, //no error and empty result
query : { "_id" : ObjectId("5649e9f35f0b360300cad022") }, //error ObjectId not defined
...

I want this

db.collection.geoNear(
  coords,
  {
  query : { _id: { $nin: poiIds } }, // no error but I have not the good results because I obtain all results geolocalized
  ...

Thank you ;-)



via DonFabiolas

No comments:

Post a Comment