I need how to do it using mapreduce functions.
The db
object has been deprecated for a long time in MRs as such it is impossible to source two tables at once within an MR.
There is another solution though: two MRs. You run a MR on the first collection first outputting to the needed collection and then you use a second MR to output to that very same collection using an out
option like reduce
or merge
to "join" to two collections together.
Of course this is slow so the better way is to not do it. As for:
select book.name,book.editions,book.characters,author.name
from dbo.book book
inner join dbo.author author on book.name=author.works_written
This query can be with streaming a cursor from the book collection and then pining the DB very quickly each book you iterate through (it's ok to do this in MongoDB) grabbing the authors details.
You can also get a set of author ids from the books and then query the authors collection all at once and sort the two out on client side.