0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
dwight 2010-11-27 18:10:59 -05:00
parent 090f393f2b
commit 8b391b1e37

View File

@ -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 : <query filter object>]");
print(" [, sort : <sort the query. useful for optimization>]");
print(" [, limit : <number of objects to return from collection>]");
print(" [, out : <output-collection name>]");
print(" [, keeptemp: <true|false>]");
print(" [, finalize : <finalizefunction>]");
print(" [, scope : <object where fields go into javascript global 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/<port>/ 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 <db_name> 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 : <query filter object>]");
print(" [, sort : <sort the query. useful for optimization>]");
print(" [, limit : <number of objects to return from collection>]");
print(" [, out : <output-collection name>]");
print(" [, keeptemp: <true|false>]");
print(" [, finalize : <finalizefunction>]");
print(" [, scope : <object where fields go into javascript global 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/<port>/ 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 <db_name> 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");
}