How do I use MongoDB to perform the SQL Join equivalent?
If you have two collections (users and comments), let's suppose that I want to retrieve all the comments with pid=444 and the user information for each.
comments
{ uid:12345, pid:444, comment="blah" }
{ uid:12345, pid:888, comment="asdf" }
{ uid:99999, pid:444, comment="qwer" }
users
{ uid:12345, name:"john" }
{ uid:99999, name:"mia" }
Is it possible to gather all the comments with a specific field (like...find(pid:444)) and the user details connected to each remark at once?
I now gather the comments that meet my requirements first, then I identify all the uids in that result set, obtain the user objects, and combine them with the results of the comments. Things seem like I'm doing it incorrectly.