How do I search through mongodb documents where documents have nested documents. For example I have a collection of private messages. Each private message has two nested doc
For MongoDB Java Driver v3.2.2. You can do something like this:
FindIterable iterable = collection.find(Document.parse("{\"sendingUser.userID\": \"34343\"}"));
FindIterable iterable = collection.find(Document.parse("{\"sendingUser.name\": \"Joe Bloggs\"}"));
You can put the $eq
inside the JSON style query string. Like {
.