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
  • 18,701
  • 13
  • 79
  • 158
Joeri Boons
  • 79
  • 1
  • 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,590
  • 15
  • 26