exists mongo code example
Example 1: mongodb exists
db.records.find( { a: { $exists: true } } )
Example 2: mongodb check if field exists java
DBObject query;
query = new BasicDBObject("fields_name", new BasicDBObject("$exists", true));
DBCursor result = collection.find(query);