假设以下投资组合集合:
{
"_id" : ObjectId("50e5a858ad06fe3439000001"),
"name" : "Portfolio 1",
"description" : "description Portfolio 1",
"userId" : "",
"wallets" : [ ]
}
{
"_id" : ObjectId("50e5a858ad06fe3439000002"),
"name" : "Portfolio 2",
"description" : "description Portfolio 2",
"userId" : "",
"wallets" : [
{
"_id" : ObjectId("50e5ac69f214a46139000001"),
"name" : "wallet name 2-1",
"description" : "description du wallet",
"cards" : [
{
"_id" : ObjectId("50ebe4b5906a1e830d000001"),
"name" : "Card 2-1-1",
"description" : "description card 1",
},
{
"_id" : ObjectId("50ebe61f2c0f189310000001"),
"name" : "Card 2-1-2",
"description" : "description de la carte",
},
{
"_id" : ObjectId("50ebe6202c0f189310000002"),
"name" : "Card 2-1-2",
"description" : "description de la carte",
},
{
"_id" : ObjectId("50ebe6212c0f189310000003"),
"name" : "Card 2-1-3",
"description" : "description de la carte",
},
{
"_id" : ObjectId("50ebe6212c0f189310000004"),
"name" : "Card 2-1-4",
"description" : "description de la carte",
}
]
},
{
"_id" : ObjectId("50ebe6b22c0f189310000005"),
"name" : "wallet 2-2",
"description" : "",
"cards" : [
{
"_id" : ObjectId("50ec21063f3c5f9f12000001"),
"name" : "Card 2-2-1",
"description" : "",
}
]
},
{
"_id" : ObjectId("50ebe6ba2c0f189310000006"),
"name" : "wallet 2-3",
"description" : "",
"cards" : [
{
"_id" : ObjectId("50ec21233f3c5f9f12000002"),
"name" : "Card 2-3-1",
"description" : "",
}
]
}
]
}
由于投资组合、钱包和卡 _id,我想访问特定卡。我想要的是:
{
"_id" : ObjectId("50e5a858ad06fe3439000002"),
"wallets" : [
{
"_id" : ObjectId("50e5ac69f214a46139000001"),
"cards" : [
{
"_id" : ObjectId("50ebe4b5906a1e830d000001"),
"name" : "Card 2-1-1",
"description" : "description card 1",
}
]
},
]
}
我正在 nodejs/mongo-native-driver 上开发 mongodb 2.2.2。
任何帮助将不胜感激(shell示例或javascript赞赏)
谢谢。