我在 mongodb 中有以下数据类型
{
"_id" : ObjectId("60007b3abc54b5305e9f5601"),
"description" : "Mens",
"name" : "Men"
}
由于上述数据已经是现有数据,现在使用 MongoClient 我想根据_id插入新的嵌入文档,如下所示
{
"_id" : ObjectId("60007b3abc54b5305e9f5601"),
"description" : "Mens",
"name" : "Men",
"subCategory" : [{
"name" : "This is name update",
"description" : "This is update"
}]
}
一次,数组已被插入,我再次需要向数组中添加另一个项目,如下所示
{
"_id" : ObjectId("60007b3abc54b5305e9f5601"),
"description" : "Mens",
"name" : "Men",
"subCategory" : [{
"name" : "This is name update",
"description" : "This is update"
},
{
"name" : "This is name update",
"description" : "This is update"
}]
}