How do I $match for specific value in json object in mongodb

Viewed 417

I use MongoDB and I have lots of JSON objects in a column that look like that:

Address (column)

[{"type":"BILLING","firstname":"XXX","lastname":"XXX","street":"XXX","city":"XXX","postcode":"78311","countryCode":"PL"}]

I would like to use a $match function to only search for results that have "countryCode":"PL" in the object (so I want to filter results based on that criteria) because I also have different results from countries all over the world.

I tried to use:

{
   $match: {address:{$in:["PL"]}
}

but unfortunately, it doesn't work. It does work for non JSON objects but not in that case. I attach a picture for better understanding, I made sure not to include personal informationenter image description here.

1 Answers
Related