0

I have a mongodb collection of documents. Each document refers to a person and the countries he has visited. The countries visited is an array of the country names.

I want to get a list of all people who have visited more than 5 countries.

Can anybody help me with a query that can be executed on robo mongo?

Thanks in Advance.

  • 1
    Can you update the question with sample documents and expected o/p for better visibility on the problem. – ambianBeing Dec 17 '19 at 09:08
  • Does this answer your question? [Query for documents where array size is greater than 1](https://stackoverflow.com/questions/7811163/query-for-documents-where-array-size-is-greater-than-1) – sudhanva Dec 17 '19 at 10:02

1 Answers1

0

Try Below query. If the name of the array is visited then:

db.getCollection('test').find({ $where:"this.visited.length>5" })