0

I'm using MongoDB v3.6.5

I have a collection called "dealers" that hold documents which look like following examples below.

{
_id: 1
country: "France"
}

{
_id: 2
country: "Belgium"
}

I have an array of country values such as;

["France","Germany","Belgium"]

I want to retrieve all documents from dealers collection where it matches values between "country" property and array values.

Ali Celebi
  • 824
  • 1
  • 10
  • 19

1 Answers1

1

Use the $in operator.

db.dealers.find( { "country" : { $in : [ "France", "Belgium" ] } } )
Ashh
  • 44,693
  • 14
  • 105
  • 132
Victor Wilson
  • 1,720
  • 1
  • 11
  • 22