diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index 14a9cb0bcd..cd52256b30 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -883,29 +883,48 @@ static v8::Handle JS_ExecuteAql (v8::Arguments const& argv) { // bind parameters TRI_json_t* parameters = nullptr; - int64_t batchSize = INT32_MAX; + + // return number of total records in cursor? + bool doCount = false; + + // maximum number of results to return at once + uint32_t batchSize = UINT32_MAX; + + // ttl for cursor + double ttl = 0.0; if (argv.Length() > 1) { if (! argv[1]->IsObject()) { TRI_V8_TYPE_ERROR(scope, "expecting object for "); } parameters = TRI_ObjectToJson(argv[1]); - } + + if (argv.Length() > 2) { + // we have options! yikes! + if (! argv[2]->IsObject()) { + TRI_V8_TYPE_ERROR(scope, "expecting object for "); + } - // TODO more options . . . - if (argv.Length() > 2) { - // we have options! yikes! - if (! argv[2]->IsObject()) { - TRI_V8_TYPE_ERROR(scope, "expecting object for "); - } + v8::Handle argValue = v8::Handle::Cast(argv[2]); + v8::Handle optionName = v8::String::New("batchSize"); - v8::Handle objValue = v8::Handle::Cast(argv[2]); - v8::Handle batchSizeName = v8::String::New("batchSize"); - if (objValue->Has(batchSizeName)) { - batchSize = TRI_ObjectToInt64(objValue->Get(batchSizeName)); - if (batchSize <= 0) { - TRI_V8_TYPE_ERROR(scope, "expecting non-negative integer for "); - // well, this makes no sense + if (argValue->Has(optionName)) { + batchSize = TRI_ObjectToInt64(argValue->Get(optionName)); + if (batchSize <= 0) { + TRI_V8_TYPE_ERROR(scope, "expecting non-negative integer for "); + // well, this makes no sense + } + } + + optionName = v8::String::New("count"); + if (argValue->Has(optionName)) { + doCount = TRI_ObjectToBoolean(argValue->Get(optionName)); + } + + optionName = v8::String::New("ttl"); + if (argValue->Has(optionName)) { + ttl = TRI_ObjectToBoolean(argValue->Get(optionName)); + ttl = (ttl <= 0.0 ? 30.0 : ttl); } } }