0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

count() in shell takes query

This commit is contained in:
Aaron 2009-05-11 16:38:15 -04:00
parent 8e36f60caa
commit 60ea7cc443
3 changed files with 15 additions and 2 deletions

11
jstests/count.js Normal file
View File

@ -0,0 +1,11 @@
t = db.jstests_count;
t.drop();
t.save( { i: 1 } );
t.save( { i: 2 } );
assert.eq( 1, t.find( { i: 1 } ).count() );
assert.eq( 1, t.count( { i: 1 } ) );
assert.eq( 2, t.find().count() );
assert.eq( 2, t.find( undefined ).count() );
assert.eq( 2, t.find( null ).count() );
assert.eq( 2, t.count() );

View File

@ -25,6 +25,7 @@
931184DC0F83C95800A6DC44 /* message_server_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = message_server_port.cpp; sourceTree = "<group>"; };
931186FB0F8535FF00A6DC44 /* bridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bridge.cpp; sourceTree = "<group>"; };
931187AE0F85463700A6DC44 /* pair3.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = pair3.js; sourceTree = "<group>"; };
931974610FB8C2BD001FE537 /* count.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = count.js; sourceTree = "<group>"; };
931A027A0F58AA4400147C0E /* jsobjmanipulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsobjmanipulator.h; sourceTree = "<group>"; };
93202DE40F879CB600AF3B71 /* all.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = all.js; sourceTree = "<group>"; };
93278F570F72D32900844664 /* gridfs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gridfs.cpp; sourceTree = "<group>"; };
@ -571,6 +572,7 @@
93A8D1D10F37544800C92B85 /* jstests */ = {
isa = PBXGroup;
children = (
931974610FB8C2BD001FE537 /* count.js */,
93BC2ADE0FB87442006BC285 /* disk */,
938DECB70FB5017A00C393D8 /* repair.js */,
93C392D00FAA4162007D6E4A /* minmax.js */,

View File

@ -248,8 +248,8 @@ DBCollection.prototype.getIndexSpecs = function(){
}
DBCollection.prototype.count = function(){
return this.find().count();
DBCollection.prototype.count = function( x ){
return this.find( x ).count();
}
/**