I have a collection and need to query on all documents where the serviceArea.regions.zipCodes have a length greater than 5 or 9, I’ve tried different approaches using $where and also $aggregate function but didn’t have any luck.
db.myCollection.find({})
serviceArea is an object and zipCodes is an array with elements:
I’ve uploaded an image of the document structure, so basically I want to get back all documents that have serviceArea.regions.zipCodes elements greater then 5 or 9 digits. In this example you will see elements displaying zipCodes with 5 digits.
Please provide real documents that we can copy directly into our installation. Retyping documents to test our idea to solve your issue is time consuming.
You repeated the same sentence as the original post. It is not clearer. Do you want that in the same query or in 2 different queries?