0

I have a collection named test something like below {"_id": ObjectId("ciwhciwiwh686ddd") "playerName": "Jon Doe" "Player Team": "Team1" "points": [ {"date": "01-01-2018", "score": 145}, {"date": "01-01-2019", "score": 200} ]

}

Went thru mongoDB official documents and tried following methods

db.test.find({"Player Team": "Team1"}, {"points": {"date":"01-01-2018"}})

I also tried

db.test.find({"Player Team": "Team1"}, {"points.date":"01-01-2018"})

I'm getting Unsupported projection option:

flowgician
  • 63
  • 1
  • 1
  • 7

1 Answers1

0

The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria.

db.test.find({"Player Team": "Team1"}, {"points": {$elemMatch {"date":"01-01-2018"}}})

flowgician
  • 63
  • 1
  • 1
  • 7