Answers for "delete specific key from every subdocuments"

0

delete specific key from every subdocuments

var deleteIdFromSubdocs = function (obj, isRoot) {
for (var key in obj) {
    if (isRoot == false && key == "_id") {
        delete obj[key];
    } else if (typeof obj[key] == "object") {
        deleteIdFromSubdocs(obj[key], false);
    }
}
return obj;
Posted by: Guest on June-08-2021

Code answers related to "delete specific key from every subdocuments"

Browse Popular Code Answers by Language