MongoDB now supports key names which contain a period (.) or starts with a $. (new in version 5.0)
They introduced new operators in the aggregation framework like $getField and $setField (docs) to work with these kind of keys but they didn't provide any examples on how to use them in the $project stage.
If I have the following collection (from the docs):
{ "_id" : 1, "item" : "sweatshirt", "price.usd": 45.99, qty: 300 }
{ "_id" : 2, "item" : "winter coat", "price.usd": 499.99, qty: 200 }
{ "_id" : 3, "item" : "sun dress", "price.usd": 199.99, qty: 250 }
how to project only the price.usd field?