我需要通过将投标插入投标数组中来更新文档,投标数组是投标的一部分。示例文档如下:
{
"_id" : "1044300051",
"Bids" : {
"Bid" : [
{
"Bidder" : {
"_id" : "pickford25",
"_Rating" : 255,
"Location" : "ANIME PARADISE",
"Country" : "USA"
},
"Time" : "Dec-07-01 15:02:54",
"Amount" : 1.12
},
{
"Bidder" : {
"_id" : "arlnwtkwsk@aol.com",
"_Rating" : 61,
"Location" : "ARCADE, NEW YORK",
"Country" : "USA"
},
"Time" : "Dec-09-01 15:02:54",
"Amount" : 1.25
}
]
}
}
以下是我尝试过的一些查询:
db.items.update({_id: "1678348584"}, {$set: {Bids: "Bid[]"}},{$push: {"Bids.Bid": {"Amount":1000}}});
db.items.update({_id: "1678348584"}, {$push: {"Bids": [{"Amount":1000}]}});
我在上述示例中尝试更新的特定 _id 最初将“Bids”设置为 null