summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-02-27 11:16:26 -0500
committerEliot Horowitz <eliot@10gen.com>2010-02-27 11:16:26 -0500
commitdd1920617207d2742ca2ae81da1b926bb5765484 (patch)
treece08725f7310c2256d5f504532c840ef04b813ff /scripting
parent11c49cb19526c02fb7411ea0efa2d608879feed1 (diff)
downloadmongo-dd1920617207d2742ca2ae81da1b926bb5765484.tar.gz
batchSize option for js and c++
Diffstat (limited to 'scripting')
-rw-r--r--scripting/sm_db.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index b15c6b8e416..1d0fe119511 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -212,7 +212,7 @@ namespace mongo {
};
JSBool mongo_find(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
- uassert( 10240 , "mongo_find neesd 5 args" , argc == 5 );
+ uassert( 10240 , "mongo_find neesd 6 args" , argc == 6 );
shared_ptr< DBClientWithCommands > * connHolder = (shared_ptr< DBClientWithCommands >*)JS_GetPrivate( cx , obj );
uassert( 10241 , "no connection!" , connHolder && connHolder->get() );
DBClientWithCommands *conn = connHolder->get();
@@ -227,10 +227,11 @@ namespace mongo {
int nToReturn = (int) c.toNumber( argv[3] );
int nToSkip = (int) c.toNumber( argv[4] );
bool slaveOk = c.getBoolean( obj , "slaveOk" );
+ int batchSize = (int) c.toNumber( argv[5] );
try {
- auto_ptr<DBClientCursor> cursor = conn->query( ns , q , nToReturn , nToSkip , f.nFields() ? &f : 0 , slaveOk ? QueryOption_SlaveOk : 0 );
+ auto_ptr<DBClientCursor> cursor = conn->query( ns , q , nToReturn , nToSkip , f.nFields() ? &f : 0 , slaveOk ? QueryOption_SlaveOk : 0 , batchSize );
if ( ! cursor.get() ){
JS_ReportError( cx , "error doing query: failed" );
return JS_FALSE;
@@ -771,6 +772,11 @@ namespace mongo {
c.setProperty( obj , "_skip" , argv[7] );
else
c.setProperty( obj , "_skip" , JSVAL_ZERO );
+
+ if ( argc > 8 && JSVAL_IS_NUMBER( argv[8] ) )
+ c.setProperty( obj , "_batchSize" , argv[8] );
+ else
+ c.setProperty( obj , "_batchSize" , JSVAL_ZERO );
c.setProperty( obj , "_cursor" , JSVAL_NULL );
c.setProperty( obj , "_numReturned" , JSVAL_ZERO );