summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorAlberto Lerner <alerner@10gen.com>2010-07-22 13:48:43 -0400
committerAlberto Lerner <alerner@10gen.com>2010-07-22 13:48:43 -0400
commitf9c5b67d117ce2d3383f678d9c1d406e6ae0046f (patch)
tree95e1afcbc4b88077314cd4c2044992d59213da58 /scripting
parentb0d3fa02f3c62dc13c5501edfaa82029cf19b84c (diff)
downloadmongo-f9c5b67d117ce2d3383f678d9c1d406e6ae0046f.tar.gz
SERVER-1278 Expose cursor buffer remains to js testing
Diffstat (limited to 'scripting')
-rw-r--r--scripting/sm_db.cpp8
-rw-r--r--scripting/v8_db.cpp13
2 files changed, 21 insertions, 0 deletions
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index 5eb5929ad8c..ce97b64eb47 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -99,6 +99,13 @@ namespace mongo {
return JS_TRUE;
}
+ JSBool internal_cursor_objsLeftInBatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
+ DBClientCursor *cursor = getCursor( cx, obj );
+ Convertor c(cx);
+ *rval = c.toval((double) cursor->objsLeftInBatch() );
+ return JS_TRUE;
+ }
+
JSBool internal_cursor_next(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){
DBClientCursor *cursor = getCursor( cx, obj );
if ( ! cursor->more() ){
@@ -114,6 +121,7 @@ namespace mongo {
JSFunctionSpec internal_cursor_functions[] = {
{ "hasNext" , internal_cursor_hasNext , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } ,
+ { "objsLeftInBatch" , internal_cursor_objsLeftInBatch , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } ,
{ "next" , internal_cursor_next , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } ,
{ 0 }
};
diff --git a/scripting/v8_db.cpp b/scripting/v8_db.cpp
index 361d5ea8a80..be1599f5c46 100644
--- a/scripting/v8_db.cpp
+++ b/scripting/v8_db.cpp
@@ -46,6 +46,7 @@ namespace mongo {
ic->InstanceTemplate()->SetInternalFieldCount( 1 );
ic->PrototypeTemplate()->Set( v8::String::New("next") , FunctionTemplate::New( internalCursorNext ) );
ic->PrototypeTemplate()->Set( v8::String::New("hasNext") , FunctionTemplate::New( internalCursorHasNext ) );
+ ic->PrototypeTemplate()->Set( v8::String::New("objsLeftInBatch") , FunctionTemplate::New( internalCursorObjsLeftInBatch ) );
proto->Set( v8::String::New( "internalCursor" ) , ic );
@@ -409,6 +410,18 @@ namespace mongo {
return Boolean::New( ret );
}
+ v8::Handle<v8::Value> internalCursorObjsLeftInBatch(const v8::Arguments& args){
+ mongo::DBClientCursor * cursor = getCursor( args );
+ if ( ! cursor )
+ return V8::Number::New( (double) 0 );
+ int ret;
+ {
+ v8::Unlocker u;
+ ret = cursor->objsLeftInBatch();
+ }
+ return V8::Number::New( (double) ret );
+ }
+
// --- DB ----