0

I'm new to MongoDB. I've imported a json file into my MongoDB. The structure looks like the following:

Structure

What I'm trying to do is get all the data for player 0, player 1,.. etc but I don't know how my db.collection.find should look.

halfer
  • 19,824
  • 17
  • 99
  • 186
Joeri Boons
  • 79
  • 2
  • 8

1 Answers1

2

Use db.collection.aggregate([{$unwind:"$match.players"}]). You cal also choose which field to project and which field to not. You can add that in the aggregation pipeline.

     db.collection.aggregate([{$unwind:"$match.players"},
                               {$project:{_id:1, player:'$match.players'}}
                             ]);
Rudra
  • 1,678
  • 16
  • 29