summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2009-08-24 11:42:15 -0400
committerDwight <dmerriman@gmail.com>2009-08-24 11:42:15 -0400
commitf67e06ba64115e4128f92fb798f46607b1a62fb5 (patch)
tree16aa442bee71d4281e89d5fa9f054d37a6cbe8a9
parent42504fc904b751ba30948a38601e26bc95f5146c (diff)
downloadmongo-f67e06ba64115e4128f92fb798f46607b1a62fb5.tar.gz
improve help for group()

-rw-r--r--db/dbcommands.cpp8
-rw-r--r--shell/collection.js1
-rw-r--r--shell/db.js1
3 files changed, 7 insertions, 3 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index f7e39afc2d4..57bc170d0f8 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -1111,7 +1111,7 @@ namespace mongo {
GroupCommand() : Command("group"){}
virtual bool slaveOk() { return true; }
virtual void help( stringstream &help ) const {
- help << "example: TODO";
+ help << "see http://www.mongodb.org/display/DOCS/Aggregation";
}
BSONObj getKey( const BSONObj& obj , const BSONObj& keyPattern , const string keyFunction , double avgSize ){
@@ -1182,6 +1182,7 @@ namespace mongo {
bool run(const char *dbname, BSONObj& jsobj, string& errmsg, BSONObjBuilder& result, bool fromRepl ){
static DBDirectClient db;
+ /* db.$cmd.findOne( { group : <p> } ) */
const BSONObj& p = jsobj.firstElement().embeddedObjectUserCheck();
BSONObj q;
@@ -1213,7 +1214,10 @@ namespace mongo {
else if ( p["$keyf"].type() ){
keyf = p["$keyf"].ascode();
}
-
+ else {
+ errmsg = "parameter 'key' is missing or not an object";
+ return false;
+ }
return group( realdbname , cursor , key , keyf , p["$reduce"].ascode() , p["initial"].embeddedObjectUserCheck() , errmsg , result );
}
diff --git a/shell/collection.js b/shell/collection.js
index e2103e4abc5..32fbc519acf 100644
--- a/shell/collection.js
+++ b/shell/collection.js
@@ -36,6 +36,7 @@ DBCollection.prototype.help = function(){
print("\tdb.foo.find(...).skip(n)");
print("\tdb.foo.find(...).count()");
print("\tdb.foo.count()");
+ print("\tdb.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
print("\tdb.foo.save(obj)");
print("\tdb.foo.update(query, object[, upsert_bool])");
print("\tdb.foo.ensureIndex(keypattern)");
diff --git a/shell/db.js b/shell/db.js
index 7cd7effddc9..0aa80cdaf34 100644
--- a/shell/db.js
+++ b/shell/db.js
@@ -261,7 +261,6 @@ DB.prototype.help = function() {
print("\tdb.getPrevError()");
print("\tdb.resetError()");
print("\tdb.getCollectionNames()");
- print("\tdb.group(ns, key[, keyf], cond, reduce, initial)");
print("\tdb.currentOp() displays the current operation in the db" );
print("\tdb.killOp() kills the current operation in the db" );
print("\tdb.version() current version of the server" );