我试图通过使用投影的查询从MongoDB检索一些文档
该文档如下所示:
{
"_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"
}
}
}
我不需要检索“class”字段,因此给定一个包含10k+结果的查询,该字段代表响应大小的很大一部分
collection.find({'_id': some_id}, {'products.*._class': 0 })
我的猜测是有某种通配符可以完成任务,但我无法找到
我试过:,$,$,$**** 但是没有成功
相关问题 更多 >
编程相关推荐