I'm trying to retrieve some documents from MongoDB through a query using projection.
The document looks something like this:
{
"_id": "01",
"country": "EUA",
"created": "2020-09-10T18:12:20.649Z",
"products": {
"0001": {
"id": "0001",
"price": "1.25",
"timestamp": "16004443546",
"class": "com.website.ecommerce.src.main.java.model.product"
},
"0123": {
"id": "0123",
"price": "1.50",
"timestamp": "16004443546",
"class": "com.website.ecommerce.src.main.java.model.product"
},
"0443": {
"id": "00443",
"price": "1.75",
"timestamp": "16004443546",
"class": "com.website.ecommerce.src.main.java.model.product"
}
}
}
I don't need the "class" field to be retrieved, so given a query with 10k+ results, this field represents a big part of the response size.
collection.find({'_id': some_id}, {'products.*._class': 0 })
My guess is that there's some kind of wildcard character will do the job, but I'm unabled to find.
I tried: , $, $, $**, ** but no success.