db.bughunt.drop;
|
db.bughunt.insertOne({
|
prices : [ {
|
max : 250,
|
min : 200
|
} ]
|
});
|
|
var doc;
|
|
////////////////////////////////////////////////////////////////////
|
// Documents that we can find by using `prices.0.min` in filter;
|
// No bug noted here, so see "NO BUG" in print output
|
////////////////////////////////////////////////////////////////////
|
|
doc = db.bughunt.findOne(\{'prices.0.min' : 200 });
|
if (doc) {
|
print ("1) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("1) BUGBUG: doc NOT found!");
|
}
|
|
doc = db.bughunt.findOne(\{'prices.0.min' : { $exists : true } });
|
if (doc) {
|
print ("2) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("2) BUGBUG: doc NOT found!");
|
}
|
|
doc = db.bughunt.findOne(\{ 'prices.0.min' : { $gt : 100 } });
|
if (doc) {
|
print ("3) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("3) BUGBUG: doc NOT found!");
|
}
|
|
doc = db.bughunt.findOne(\{ 'prices.0.min' : { $exists : true, $ne : 123 } });
|
if (doc) {
|
print ("4) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("4) BUGBUG: doc NOT found!");
|
}
|
|
////////////////////////////////////////////////////////////////////
|
// Documents that we CANNOT find using `prices.0.min` in filter;
|
// BUG noted here, so see "BUGBUG" in print output
|
////////////////////////////////////////////////////////////////////
|
|
doc = db.bughunt.findOne(\{ 'prices.0.min' : { $exists : true, $ne : null } });
|
if (doc) {
|
print ("5) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("5) BUGBUG: doc NOT found!");
|
}
|
|
doc = db.bughunt.findOne(\{ 'prices.0.min' : { $ne : null } });
|
if (doc) {
|
print ("6) NO BUG: doc found");
|
print (tojson(doc));
|
} else {
|
print ("6) BUGBUG: doc NOT found!");
|
}
|
|
print ("Bughunt finished!");
|