How can I combine data from multiple collections into one collection?

Technology CommunityCategory: MongoDBHow can I combine data from multiple collections into one collection?
VietMX Staff asked 3 years ago

MongoDB 3.2 allows one to combine data from multiple collections into one through the $lookup aggregation stage.

db.books.aggregate([{
    $lookup: {
            from: "books_selling_data",
            localField: "isbn",
            foreignField: "isbn",
            as: "copies_sold"
        }
}])