1
我正在使用下面的代码...但是如果状态为空的iss显示下面的结果数据库中...我想删除如果状态为空..如何删除{}中的空字段.. nodejs
1地址{},状态{}保存在数据库中。
function CheckStatus(oldJob, newJob) {
var obj = {};
if(newJob && newJob.Status) {
obj.Status= {};
if (oldJob.Status.total !== newJob.Status.total) {
obj.Status.total = newJob.Status.total;
}
if (oldJob.Status.charge_description && oldJob.Status.charge_description !== newJob.Status.charge_description) {
obj.Status.charge_description = newJob.Status.charge_description;
}
}
}
MongoDB的
"Job" : {
"_id" : ObjectId("5873b352e7621d08fccc5890"),
"updated_by" : "",
"details" : "{\"current_status\":\"Completed\",\"address\":{},\"Status\":{}}",
"changetype" : "Update",
"datetime" : ISODate("2017-01-09T15:59:14.202Z")
},
请帮什么If条件是如何进入(下面的代码不工作)
if(obj.address = '{}')
{
console.log('Empty');
}
我改变了我的代码.. if(obj.address ='undefined')不工作 –
您是否阅读过我引用的问题?我只回答了“删除”一个变量的部分。另外,你应该检查没有引号的未定义。你永远不会用一个等号进行比较。 –
if(obj.address == undefined)not working when when if(obj.address = undefined)..这个工作只是空的。 –