2014-07-18 15:27:28 +02:00
|
|
|
// 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 } );
|
|
|
|
|
2015-01-13 00:13:52 +01:00
|
|
|
res = mydb.runCommand( "listCollections" );
|
2014-12-16 20:23:48 +01:00
|
|
|
collections = new DBCommandCursor( db.getMongo(), res ).toArray();
|
2014-07-18 15:27:28 +02:00
|
|
|
|
2014-12-16 20:23:48 +01:00
|
|
|
bar = collections.filter( function(x){ return x.name == "bar"; } )[0];
|
|
|
|
foo = collections.filter( function(x){ return x.name == "foo" ; } )[0];
|
2014-07-18 15:27:28 +02:00
|
|
|
|
|
|
|
assert( bar );
|
|
|
|
assert( foo );
|
|
|
|
|
|
|
|
assert.eq( bar.name, mydb.bar.getName() );
|
|
|
|
assert.eq( foo.name, mydb.foo.getName() );
|
|
|
|
|
|
|
|
assert( mydb.bar.temp, tojson( bar ) );
|
|
|
|
|
2014-12-16 20:23:48 +01:00
|
|
|
getCollectionName = function(infoObj) { return infoObj.name; }
|
2014-07-18 15:27:28 +02:00
|
|
|
|
2014-12-16 20:23:48 +01:00
|
|
|
assert.eq( mydb._getCollectionInfosSystemNamespaces().map(getCollectionName),
|
|
|
|
mydb._getCollectionInfosCommand().map(getCollectionName) );
|
|
|
|
|
|
|
|
assert.eq( mydb.getCollectionInfos().map(getCollectionName),
|
|
|
|
mydb._getCollectionInfosCommand().map(getCollectionName) );
|
2014-07-18 15:27:28 +02:00
|
|
|
|
|
|
|
mydb.dropDatabase();
|