I have a below data type in mongodb
{
"_id" : ObjectId("60007b3abc54b5305e9f5601"),
"description" : "Mens",
"name" : "Men"
}
Since the above data is already an existing data, Now using the MongoClient I want to insert the new embedded document based on the _id as below
{
"_id" : ObjectId("60007b3abc54b5305e9f5601"),
"description" : "Mens",
"name" : "Men",
"subCategory" : [{
"name" : "This is name update",
"description" : "This is update"
}]
}
Once, the array has been inserted, Again I have the requirement to add another item to the array, something like below
{
"_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"
}]
}
question from:
https://stackoverflow.com/questions/65860018/java-mongoclient-to-add-a-new-embedded-document 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…