I have a collection like this.
System
{
System_id: 100,
system_type:
{
[
{
Tenant_Id: 1,
Tenant_Info: "check",
Prop_Info: ...
},
{
Tenant_Id: 2,
Tenant_Info: "sucess",
Prop_Info: ...
} ]
}
I need to remove the only one embedded document where the tenant_id is 1 and system_id s 100 using java api.
I have tried to delete the document. But the whole document is getting deleted. I need to delete only the embedded document where tenant_id is 1.
DBCollection collection=db.getCollection("system");
field.put("system_id",100);
field.put("system_type.Tenant_id", 1);
collection.remove(field);
Kindly guide me how to delete it? I need the output like this.
System
{
System_id: 100,
system_type:
{
[
{
Tenant_Id: 2,
Tenant_Info: "sucess",
Prop_Info: ...
} ]
}