Permalink
Browse files

collection._distinct helper to get raw info

  • Loading branch information...
1 parent 14ef6d6 commit b49e9338db5b3c20996113fcc0e9f1d4ed3b4bf4 @erh erh committed Mar 23, 2011
Showing with 18 additions and 2 deletions.
  1. +9 −1 shell/collection.js
  2. +9 −1 shell/mongo_vstudio.cpp
View
@@ -530,13 +530,21 @@ DBCollection.prototype.isCapped = function(){
return ( e && e.options && e.options.capped ) ? true : false;
}
+DBCollection.prototype._distinct = function( keyString , query ){
+ return this._dbCommand( { distinct : this._shortName , key : keyString , query : query || {} } );
+ if ( ! res.ok )
+ throw "distinct failed: " + tojson( res );
+ return res.values;
+}
+
DBCollection.prototype.distinct = function( keyString , query ){
- var res = this._dbCommand( { distinct : this._shortName , key : keyString , query : query || {} } );
+ var res = this._distinct( keyString , query );
if ( ! res.ok )
throw "distinct failed: " + tojson( res );
return res.values;
}
+
DBCollection.prototype.group = function( params ){
params.ns = this._shortName;
return this._db.group( params );
@@ -3331,13 +3331,21 @@ const StringData _jscode_raw_collection =
"return ( e && e.options && e.options.capped ) ? true : false;\n"
"}\n"
"\n"
+"DBCollection.prototype._distinct = function( keyString , query ){\n"
+"return this._dbCommand( { distinct : this._shortName , key : keyString , query : query || {} } );\n"
+"if ( ! res.ok )\n"
+"throw \"distinct failed: \" + tojson( res );\n"
+"return res.values;\n"
+"}\n"
+"\n"
"DBCollection.prototype.distinct = function( keyString , query ){\n"
-"var res = this._dbCommand( { distinct : this._shortName , key : keyString , query : query || {} } );\n"
+"var res = this._distinct( keyString , query );\n"
"if ( ! res.ok )\n"
"throw \"distinct failed: \" + tojson( res );\n"
"return res.values;\n"
"}\n"
"\n"
+"\n"
"DBCollection.prototype.group = function( params ){\n"
"params.ns = this._shortName;\n"
"return this._db.group( params );\n"

0 comments on commit b49e933

Please sign in to comment.