check field exists in mongodb code example
Example 1: mongodb exists and not null
db.collection1.find({ 'fieldname1' : { $exists: true, $ne: null } });
Example 2: mongodb check if field exists
db.records.find( { a: { $exists: true } } )
db.collection1.find({ 'fieldname1' : { $exists: true, $ne: null } });
db.records.find( { a: { $exists: true } } )