|
It gets worse - having ANYTHING between the ( and ) for cursor.count() is interpreted as setting applySkipLimit to true, even when user intentions are clearly otherwise:
db.MyColl.find().limit(10).count({}, {limit:5})
|
10
|
|
db.MyColl.find().limit(10).count({applySkipLimit:true})
|
10
|
|
db.MyColl.find().limit(10).count({applySkipLimit:false})
|
10
|
The correct way to specify applySkipLimit (see below) is not clear from our documentation:
db.MyColl.find().limit(10).count(true)
|
10
|
db.MyColl.find().limit(10).count(false)
|
20
|
It is also not clear to users which of the cursor.count() and db.collection.count() syntaxes will be applied to the arguments passed with count(). For example, only the last of these four commands is doing what the user expected, but the are no warning or error messages from the other three usages:
db.MyColl.find().count({limit:5})
|
20
|
db.MyColl.find().count({}, {limit:5})
|
20
|
db.MyColl.count({limit:5})
|
0
|
db.filemeta.count({}, {limit:5})
|
5
|
If (for backwards compatibility reasons) we cannot change the behaviour of the code, the least we could do is update the documentation to:
- include examples of setting applySkipLimit to both true and false
- make clearer to users the difference between db.collection.find().count() and db.collection.count()
|