-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Querying
> db.docs.drop() > for (var i=0; i<10; i++) { db.docs.insert({number: i}) } > db.docs.find() { "_id" : ObjectId("51834d678d284e5c5e3ea7e3"), "number" : 0 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e4"), "number" : 1 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e5"), "number" : 2 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e6"), "number" : 3 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e7"), "number" : 4 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e8"), "number" : 5 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e9"), "number" : 6 } { "_id" : ObjectId("51834d678d284e5c5e3ea7ea"), "number" : 7 } { "_id" : ObjectId("51834d678d284e5c5e3ea7eb"), "number" : 8 } { "_id" : ObjectId("51834d678d284e5c5e3ea7ec"), "number" : 9 } > db.docs.count() 10
> db.docs.find().max({number: 4}) { "_id" : ObjectId("51834d678d284e5c5e3ea7e3"), "number" : 0 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e4"), "number" : 1 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e5"), "number" : 2 } { "_id" : ObjectId("51834d678d284e5c5e3ea7e6"), "number" : 3 }
So far so good.
> db.docs.find().max({number: 4}).count() 10
I would like this count to return 4. Instead it returns 10.
- is duplicated by
-
SERVER-675 count() broken with $min and $max
- Closed