vendredi 30 janvier 2015

mongodb field is never null?


I have the following in a js:



var deletedCursor = db.packets.find(
{ "deleted": "1" }
).limit(10).sort({ "packet.datetime": -1 });

deletedCursor.forEach( function( doc ){
print( "Document ID: " + doc["_id"] );
if( doc["packet"]["otid"]==null ){ print("OTID is NULL"); }else{ print("OTID doesnt show as null: " + doc["packet"]["otid"] ); }
if( doc["packet"]["dtid"]==null ){ print("DTID is NULL"); }else{ print("DTID doesnt show as null: " + doc["packet"]["dtid"] ); }
}


But that "null" comparison is NEVER true, even though the field IS null (or empty), how can i check this?



Document ID: 54cbbbef7f1b0586f29b44b6
OTID doesnt show as null: M2PA042C1AB2
DTID doesnt show as null:


EDIT:


As an example of a doc:



{
"_id" : ObjectId("54cbc2027f1b0586f2a09688"),
"deleted" : "1",
"packet" : {
"datetime" : ISODate("2015-01-30T17:39:30.896Z"),
"signallingType" : "M2PA",
"clgNum" : "91255",
"cldNum" : "",
"opc" : "6407",
"dpc" : "327",
"transState" : "begin",
"otid" : "M2PA04276210",
"dtid" : "",
"sccpCalling" : "5233",
"sccpCalled" : "5233",
"imsi" : "",
"operation" : "initialDPSMS (60)",
"camelClgNum" : "",
"camelCldNum" : "",
"camelCallRefNum" : "",
"camelImsi" : "...",
"camelEvent" : "",
"camelReleaseCause" : "",
"pcapFileName" : "/home/monitor/tmp/tmp/gsm_eth2_25053_20150130113917.pcap",
"message" : "..."
}
}


Thanks for your help!


David





Aucun commentaire:

Enregistrer un commentaire