我有像这个例子的集合
{ "_id" : { "$oid" : "594989c638773060134b8442" },
"rank" : 10.0, "brand" : "Dodge", "model" : "Viper",
"engineSpec" : { "cylinderConfig" : "V-10", "engineLiters" : 8.4, "transmission" : "6 speed manual" } }
如果我提出请求
collection.find()
.projection(Projections.include("engineSpec"))
.forEach((Block<Document>) set ->{
System.out.println(set.toJson());
});
我喜欢这个
{ "_id" : { "$oid" : "594989c638773060134b8442" },
"engineSpec" : { "cylinderConfig" :
"V-10",
"engineLiters" : 8.4,
"transmission" : "6 speed manual" } }
我想得到这个例子中的集合
{ "_id" : { "$oid" : "594989c638773060134b8442" },
"engineSpec" : {"transmission" : "6 speed manual" } }