@persten: I don't want to sound callous, but the answer to your
question is basically "you don't". MongoDB is not a relational
database and is not intended to perform such relational queries.
Asking this question indicates that you may fundamentally
misunderstand how MongoDB works.
The simple answer to your question is that you'll need to write some
for loops. One to load the data from one collection and another to
load data from the second collection.
However, the more detailed answer is that you need to re-think your
queries. You give the following query which is bad for a couple of
reasons:
SELECT n.*, u.*
FROM news AS n
INNER JOIN users AS u ON n.user_id =
u.id
1. There's no where clause. Why do you need every single news item
joined to every single user? What if you have 100M users and 2B news
items what are you going to do with this data? The where clause is
going to tell us something about how you want to query, it should be
there.
2. There are no specific columns. Why do you need a user's password
with every news item?
The standard solutions here are simple:
1. Store an array of News.ID inside of each user object.
2. Store some of the User Data inside of the News item.
If you can give us some better queries, then we can give you some
better answers.