Join two collections in MongoDB

前端 未结 5 711
旧时难觅i
旧时难觅i 2021-01-23 18:33

Am a beginner in mongoDB. I have two collections Book and author. [name and workswritten] are the common column respectively. Using inner join I have to emit the some columns in

5条回答
  •  遥遥无期
    2021-01-23 19:28

    Try this:-

    db.book.aggregate([
        {
          $lookup:
            {
              from: "author",
              localField: "name",
              foreignField: "works_written",
              as: "nameWorkData"
            }
       }
    ])
    

提交回复
热议问题