让:
{
[
{
"_id": ObjectId("5d02425b88657d20347ba1e9"),
"label1": "value1",
},
{
"_id": ObjectId("5d02425b88657d20347ba1ea"),
"label1": "value1",
},
{
"_id": ObjectId("5d02425b88657d20347ba1eb"),
"label1": "value1",
},
]
}
我正在返回包含
的对象数组db.Tasks.aggregate([{$project: {"_id":0, "id":"$_id"}}])
这将返回
{ "id" : ObjectId("5d02425b88657d20347ba1e9") }
{ "id" : ObjectId("5d02431688657d20347ba1ea") }
{ "id" : ObjectId("5d02441c88657d20347ba1eb") }
如何进行投影,使其在没有ObjectId包装器的情况下返回(如下面所示)?
{"id": "5d02425b88657d20347ba1e9"}
{"id": "5d02425b88657d20347ba1ea"}
{"id": "5d02425b88657d20347ba1eb"}