0

I am new to mongo. I have 5 collections and I need to execute a single query to check if any document matches the condition {"objectName":"namevalue"} in any of these collections. If so then I need to take those collection(s) and use it for another query. I am using a java driver for mongo. How do i do this?

thanks in advance...

Akhil Achuthan
  • 141
  • 3
  • 16
  • 1
    You'll have to run 5 separate queries against each of the collections. There's no other way around. There's no concept of `joins` in MongoDB, so you'll always be running queries against a single collection. – Anand Jayabalan Apr 11 '14 at 15:14
  • possible duplicate of [MongoDB - Search on multiple collections](http://stackoverflow.com/questions/20056903/mongodb-search-on-multiple-collections). Have a look at the [first answer](http://stackoverflow.com/a/20059202/347455). You can't do joins in mongodb, and this is by design. – pennstatephil Apr 11 '14 at 15:15
  • A better example would be to actually show some data and you intended result. You seem to be approaching this from a very "relational" mindset. That is not a good idea given the tool you are choosing to use. – Neil Lunn Apr 11 '14 at 15:17

0 Answers0