我有两种收藏:
fieldMappingViewModel.MappedFields():
[
{ "EmailField" : "FirstName", "CrmField" : "FirstName" },
{ "EmailField" : "LastName", "CrmField" : "LastName" },
{ "EmailField" : "Job", "CrmField" : "JobTitle" }...
]
_全部:
[
{ "EmailField" : "FirstName", "CrmField" : null },
{ "EmailField" : "LastName", "CrmField" : "LastName" },
{ "EmailField" : "Job", "CrmField" : "JobTitle" }...
]
我正在尝试使用以下方法创建这两者的独特联合:
fieldMappingViewModel.allMappings(_.uniq(_.union(fieldMappingViewModel.MappedFields(), _all),
function (item, key) {
// not the ones that their item.EmailField() already exists with a CrmField value
}));
当然,严格相等仍然存在于具有重复电子邮件字段但其 CrmField 不同的结果对象中。
如何从我的最终结果中摆脱带有 CrmField: Null 的那些?(我只想过滤那些存在非空对的空值。否则我想保留其中包含空值的对)
所以我最终没有
{ "EmailField" : "FirstName", "CrmField" : "FirstName" }
和
{ "EmailField" : "FirstName", "CrmField" : null }
两者都在最终结果中。但只有:
{ "EmailField" : "FirstName", "CrmField" : "FirstName" }