I have following collection which looks like below:-
{
"_id" : ObjectId("5aba0f8fd19bc9314089a9ba"),
"repoha" : [ ],
"name" : "myrep2",
"repo_number" : 4,
"store_front_port" : null,
"old_repo_paths" : [
{
"path" : "/opt/immune/storage/",
"retention" : 2
},
{
"path" : "/secondarytier/",
"retention" : 10
},
{
"path" : "/teritarydir/dir1/",
"retention" : 3
}
],
"repopath" : [
{
"path" : "/opt/immune/storage/",
"retention" : 2
},
{
"path" : "/teritarydir/dir1/",
"retention" : 3
}
],
"tid" : "",
"used_size" : "0.00781 MB",
}
how to remove the key named "old_repo_paths" and with any value in it so that collection will look like
{
"_id" : ObjectId("5aba0f8fd19bc9314089a9ba"),
"repoha" : [ ],
"name" : "myrep2",
"repopath" : [
{
"path" : "/opt/immune/storage/",
"retention" : 2
},
{
"path" : "/teritarydir/dir1/",
"retention" : 3
}
],
"tid" : "",
"used_size" : "0.00781 MB",
}
I have tried unset method along but getting errors
db.repo.update({_id:ObjectId("5aba0f8fd19bc9314089a9ba")},{$unset: {old_repo_paths}});