【发布时间】:2015-07-23 03:34:54
【问题描述】:
有没有办法在嵌套对象属性上使用_.omit?
我希望这发生:
schema = {
firstName: {
type: String
},
secret: {
type: String,
optional: true,
private: true
}
};
schema = _.nestedOmit(schema, 'private');
console.log(schema);
// Should Log
// {
// firstName: {
// type: String
// },
// secret: {
// type: String,
// optional: true
// }
// }
_.nestedOmit 显然不存在,只是_.omit 不会影响嵌套属性,但应该清楚我在寻找什么。
它也不必是下划线,但根据我的经验,它通常只会让事情变得更短更清晰。
【问题讨论】:
-
嵌套是任意的还是只有一层?