From 8b391b1e378cbe3b7b06a62a97a6bf58f553f3a3 Mon Sep 17 00:00:00 2001 From: dwight Date: Sat, 27 Nov 2010 18:10:59 -0500 Subject: [PATCH] help --- shell/utils.js | 187 +++++++++++++++++++++++++------------------------ 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/shell/utils.js b/shell/utils.js index d4760d91b23..ea6475a55a8 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -1356,97 +1356,98 @@ rs.remove = function (hn) { } return "error: couldn't find "+hn+" in "+tojson(c.members); -}; - -help = shellHelper.help = function (x) { - if (x == "mr") { - print("\nSee also http://www.mongodb.org/display/DOCS/MapReduce"); - print("\nfunction mapf() {"); - print(" // 'this' holds current document to inspect"); - print(" emit(key, value);"); - print("}"); - print("\nfunction reducef(key,value_array) {"); - print(" return reduced_value;"); - print("}"); - print("\ndb.mycollection.mapReduce(mapf, reducef[, options])"); - print("\noptions"); - print("{[query : ]"); - print(" [, sort : ]"); - print(" [, limit : ]"); - print(" [, out : ]"); - print(" [, keeptemp: ]"); - print(" [, finalize : ]"); - print(" [, scope : ]"); - print(" [, verbose : true]}\n"); - return; - } else if (x == "connect") { - print("\nNormally one specifies the server on the mongo shell command line. Run mongo --help to see those options."); - print("Additional connections may be opened:\n"); - print(" var x = new Mongo('host[:port]');"); - print(" var mydb = x.getDB('mydb');"); - print(" or"); - print(" var mydb = connect('host[:port]/mydb');"); - print("\nNote: the REPL prompt only auto-reports getLastError() for the shell command line connection.\n"); - return; - } - else if (x == "misc") { - print("\tb = new BinData(subtype,base64str) create a BSON BinData value"); - print("\tb.subtype() the BinData subtype (0..255)"); - print("\tb.length() length of the BinData data in bytes"); - print("\tb.hex() the data as a hex encoded string"); - print("\tb.base64() the data as a base 64 encoded string"); - print("\tb.toString()"); - print(); - print("\to = new ObjectId() create a new ObjectId"); - print("\to.getTimestamp() return timestamp derived from first 32 bits of the OID"); - print("\to.isObjectId()"); - print("\to.toString()"); - print("\to.equals(otherid)"); - return; - } - else if (x == "admin") { - print("\tls([path]) list files"); - print("\tpwd() returns current directory"); - print("\tlistFiles([path]) returns file list"); - print("\thostname() returns name of this host"); - print("\tcat(fname) returns contents of text file as a string"); - print("\tremoveFile(f) delete a file"); - print("\tload(jsfilename) load and execute a .js file"); - print("\trun(program[, args...]) spawn a program and wait for its completion"); - print("\tsleep(m) sleep m milliseconds"); - print("\tgetMemInfo() diagnostic"); - return; - } - else if (x == "test") { - print("\tstartMongodEmpty(args) DELETES DATA DIR and then starts mongod"); - print("\t returns a connection to the new server"); - print("\tstartMongodTest() DELETES DATA DIR"); - print("\t automatically picks port #s starting at 27000 and increasing"); - print("\t or you can specify the port as the first arg"); - print("\t dir is /data/db// if not specified as the 2nd arg"); - print("\t returns a connection to the new server"); - return; - } - else if (x == "") { - print("\t" + "db.help() help on db methods"); - print("\t" + "db.mycoll.help() help on collection methods"); - print("\t" + "rs.help() help on replica set methods"); - print("\t" + "help connect connecting to a db help"); - print("\t" + "help admin administrative help"); - print("\t" + "help misc misc things to know"); - print("\t" + "help mr mapreduce help"); - print(); - print("\t" + "show dbs show database names"); - print("\t" + "show collections show collections in current database"); - print("\t" + "show users show users in current database"); - print("\t" + "show profile show most recent system.profile entries with time >= 1ms"); - print("\t" + "use set current database"); - print("\t" + "db.foo.find() list objects in collection foo"); - print("\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1"); - print("\t" + "it result of the last line evaluated; use to further iterate"); - print("\t" + "DBQuery.shellBatchSize = x set default number of items to display on shell"); - print("\t" + "exit quit the mongo shell"); - } - else - print("unknown help option"); +}; + +help = shellHelper.help = function (x) { + if (x == "mr") { + print("\nSee also http://www.mongodb.org/display/DOCS/MapReduce"); + print("\nfunction mapf() {"); + print(" // 'this' holds current document to inspect"); + print(" emit(key, value);"); + print("}"); + print("\nfunction reducef(key,value_array) {"); + print(" return reduced_value;"); + print("}"); + print("\ndb.mycollection.mapReduce(mapf, reducef[, options])"); + print("\noptions"); + print("{[query : ]"); + print(" [, sort : ]"); + print(" [, limit : ]"); + print(" [, out : ]"); + print(" [, keeptemp: ]"); + print(" [, finalize : ]"); + print(" [, scope : ]"); + print(" [, verbose : true]}\n"); + return; + } else if (x == "connect") { + print("\nNormally one specifies the server on the mongo shell command line. Run mongo --help to see those options."); + print("Additional connections may be opened:\n"); + print(" var x = new Mongo('host[:port]');"); + print(" var mydb = x.getDB('mydb');"); + print(" or"); + print(" var mydb = connect('host[:port]/mydb');"); + print("\nNote: the REPL prompt only auto-reports getLastError() for the shell command line connection.\n"); + return; + } + else if (x == "misc") { + print("\tb = new BinData(subtype,base64str) create a BSON BinData value"); + print("\tb.subtype() the BinData subtype (0..255)"); + print("\tb.length() length of the BinData data in bytes"); + print("\tb.hex() the data as a hex encoded string"); + print("\tb.base64() the data as a base 64 encoded string"); + print("\tb.toString()"); + print(); + print("\to = new ObjectId() create a new ObjectId"); + print("\to.getTimestamp() return timestamp derived from first 32 bits of the OID"); + print("\to.isObjectId()"); + print("\to.toString()"); + print("\to.equals(otherid)"); + return; + } + else if (x == "admin") { + print("\tls([path]) list files"); + print("\tpwd() returns current directory"); + print("\tlistFiles([path]) returns file list"); + print("\thostname() returns name of this host"); + print("\tcat(fname) returns contents of text file as a string"); + print("\tremoveFile(f) delete a file"); + print("\tload(jsfilename) load and execute a .js file"); + print("\trun(program[, args...]) spawn a program and wait for its completion"); + print("\tsleep(m) sleep m milliseconds"); + print("\tgetMemInfo() diagnostic"); + return; + } + else if (x == "test") { + print("\tstartMongodEmpty(args) DELETES DATA DIR and then starts mongod"); + print("\t returns a connection to the new server"); + print("\tstartMongodTest() DELETES DATA DIR"); + print("\t automatically picks port #s starting at 27000 and increasing"); + print("\t or you can specify the port as the first arg"); + print("\t dir is /data/db// if not specified as the 2nd arg"); + print("\t returns a connection to the new server"); + print("\tresetDbpath(dirpathstr) deletes everything under the dir specified including subdirs"); + return; + } + else if (x == "") { + print("\t" + "db.help() help on db methods"); + print("\t" + "db.mycoll.help() help on collection methods"); + print("\t" + "rs.help() help on replica set methods"); + print("\t" + "help connect connecting to a db help"); + print("\t" + "help admin administrative help"); + print("\t" + "help misc misc things to know"); + print("\t" + "help mr mapreduce help"); + print(); + print("\t" + "show dbs show database names"); + print("\t" + "show collections show collections in current database"); + print("\t" + "show users show users in current database"); + print("\t" + "show profile show most recent system.profile entries with time >= 1ms"); + print("\t" + "use set current database"); + print("\t" + "db.foo.find() list objects in collection foo"); + print("\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1"); + print("\t" + "it result of the last line evaluated; use to further iterate"); + print("\t" + "DBQuery.shellBatchSize = x set default number of items to display on shell"); + print("\t" + "exit quit the mongo shell"); + } + else + print("unknown help option"); }