0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-29 00:32:18 +01:00
mongodb/jstests/mmap_v1/list_collections2.js
Jason Rassi 0aede468dc SERVER-16518 listCollections response changed to cursor object form
As a temporary compatibility measure, the legacy behavior is preserved
if the "cursor" option is not sent with the command.  This
compatibility layer will be removed as part of work for the parent
ticket.
2014-12-16 14:31:58 -05:00

33 lines
1011 B
JavaScript

// Test the listCollections command and system.namespaces
mydb = db.getSisterDB( "list_collections1" );
mydb.dropDatabase();
mydb.foo.insert( { x : 5 } );
mydb.runCommand( { create : "bar", temp : true } );
res = mydb.runCommand( "listCollections", { cursor : {} } );
collections = new DBCommandCursor( db.getMongo(), res ).toArray();
bar = collections.filter( function(x){ return x.name == "bar"; } )[0];
foo = collections.filter( function(x){ return x.name == "foo" ; } )[0];
assert( bar );
assert( foo );
assert.eq( bar.name, mydb.bar.getName() );
assert.eq( foo.name, mydb.foo.getName() );
assert( mydb.bar.temp, tojson( bar ) );
getCollectionName = function(infoObj) { return infoObj.name; }
assert.eq( mydb._getCollectionInfosSystemNamespaces().map(getCollectionName),
mydb._getCollectionInfosCommand().map(getCollectionName) );
assert.eq( mydb.getCollectionInfos().map(getCollectionName),
mydb._getCollectionInfosCommand().map(getCollectionName) );
mydb.dropDatabase();