0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

Updated db.foo.help() to include name of the db to facilitate copy/paste.

This commit is contained in:
Jay Ridgeway 2010-04-20 04:43:46 +08:00 committed by Eliot
parent 8afdf52bad
commit 2d818b6e4f

View File

@ -27,38 +27,39 @@ DBCollection.prototype.getName = function(){
} }
DBCollection.prototype.help = function() { DBCollection.prototype.help = function() {
var shortName = this.getName();
print("DBCollection help"); print("DBCollection help");
print("\tdb.foo.count()"); print("\tdb."+shortName+".count()");
print("\tdb.foo.dataSize()"); print("\tdb."+shortName+".dataSize()");
print("\tdb.foo.distinct( key ) - eg. db.foo.distinct( 'x' )"); print("\tdb."+shortName+".distinct( key ) - eg. db."+shortName+".distinct( 'x' )");
print("\tdb.foo.drop() drop the collection"); print("\tdb."+shortName+".drop() drop the collection");
print("\tdb.foo.dropIndex(name)"); print("\tdb."+shortName+".dropIndex(name)");
print("\tdb.foo.dropIndexes()"); print("\tdb."+shortName+".dropIndexes()");
print("\tdb.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups"); print("\tdb."+shortName+".ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups");
print("\tdb.foo.reIndex()"); print("\tdb."+shortName+".reIndex()");
print("\tdb.foo.find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return."); print("\tdb."+shortName+".find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return.");
print("\t e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )"); print("\t e.g. db."+shortName+".find( { x : 77 } , { name : 1 , x : 1 } )");
print("\tdb.foo.find(...).count()"); print("\tdb."+shortName+".find(...).count()");
print("\tdb.foo.find(...).limit(n)"); print("\tdb."+shortName+".find(...).limit(n)");
print("\tdb.foo.find(...).skip(n)"); print("\tdb."+shortName+".find(...).skip(n)");
print("\tdb.foo.find(...).sort(...)"); print("\tdb."+shortName+".find(...).sort(...)");
print("\tdb.foo.findOne([query])"); print("\tdb."+shortName+".findOne([query])");
print("\tdb.foo.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )"); print("\tdb."+shortName+".findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )");
print("\tdb.foo.getDB() get DB object associated with collection"); print("\tdb."+shortName+".getDB() get DB object associated with collection");
print("\tdb.foo.getIndexes()"); print("\tdb."+shortName+".getIndexes()");
print("\tdb.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )"); print("\tdb."+shortName+".group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
print("\tdb.foo.mapReduce( mapFunction , reduceFunction , <optional params> )"); print("\tdb."+shortName+".mapReduce( mapFunction , reduceFunction , <optional params> )");
print("\tdb.foo.remove(query)"); print("\tdb."+shortName+".remove(query)");
print("\tdb.foo.renameCollection( newName , <dropTarget> ) renames the collection."); print("\tdb."+shortName+".renameCollection( newName , <dropTarget> ) renames the collection.");
print("\tdb.foo.runCommand( name , <options> ) runs a db command with the given name where the 1st param is the colleciton name" ); print("\tdb."+shortName+".runCommand( name , <options> ) runs a db command with the given name where the 1st param is the colleciton name" );
print("\tdb.foo.save(obj)"); print("\tdb."+shortName+".save(obj)");
print("\tdb.foo.stats()"); print("\tdb."+shortName+".stats()");
print("\tdb.foo.storageSize() - includes free space allocated to this collection"); print("\tdb."+shortName+".storageSize() - includes free space allocated to this collection");
print("\tdb.foo.totalIndexSize() - size in bytes of all the indexes"); print("\tdb."+shortName+".totalIndexSize() - size in bytes of all the indexes");
print("\tdb.foo.totalSize() - storage allocated for all data and indexes"); print("\tdb."+shortName+".totalSize() - storage allocated for all data and indexes");
print("\tdb.foo.update(query, object[, upsert_bool, multi_bool])"); print("\tdb."+shortName+".update(query, object[, upsert_bool, multi_bool])");
print("\tdb.foo.validate() - SLOW"); print("\tdb."+shortName+".validate() - SLOW");
print("\tdb.foo.getShardVersion() - only for use with sharding"); print("\tdb."+shortName+".getShardVersion() - only for use with sharding");
} }
DBCollection.prototype.getFullName = function(){ DBCollection.prototype.getFullName = function(){