📌  相关文章
📜  从每个子文档中删除特定键 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:04.226000             🧑  作者: Mango

代码示例1
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;