how to join two tables in mongodb

后端 未结 3 482
太阳男子
太阳男子 2020-12-11 12:52

how to join two tables in mongodb.

For example, table 1 : users table 2 : examples

Here users table having username and examples table also having username,

相关标签:
3条回答
  • 2020-12-11 13:03

    Unfortunately there is no merging/joining operation directly in MongoDB. Anyway, you can use the map-and-reduce functionality in order to combine the data appropriately.

    Depending on your actual problem, the following links might be of help:

    MongoDB: Combine data from multiple collections into one..how?

    Merging two collections in MongoDB

    http://www.pal-blog.de/entwicklung/mongodb/mapreduce-multiple-mongodb-collections-into-one.html

    https://groups.google.com/forum/#!topic/mongodb-user/OQUH_wxYyRg

    https://groups.google.com/forum/#!topic/mongodb-user/qxa7ZBTk7sQ

    0 讨论(0)
  • 2020-12-11 13:10

    I would personally recommend you stop using Map Reduce for this before you start (in reference to the other answers).

    As a person who has had to do MongoDB JOINs in an actual production application I can tell you that Map Reduce is probably the worst method imaginable for this solution.

    It was back in 2012 and it is now.

    The only beneift you have in current versions of MongoDB is that many isolates can run concurrently instead of just one at a time (imagine single threaded JOINs across ALL connections in 2012 :\, this was and is a terrible idea).

    You want to implement this in the client side, pulling the records out all at once from the disparate collections and merging them within your application logic. That is the only real sure way to scale a JOIN in MongoDB.

    0 讨论(0)
  • 2020-12-11 13:22

    There is nothing like join in mongodb

    Check below answer

    MongoDB: Combine data from multiple collections into one..how?

    0 讨论(0)
提交回复
热议问题