mirror of https://gitee.com/bigwinds/arangodb
added additional options to JS_ExecuteAql.
This commit is contained in:
parent
b5327b3770
commit
eb6cf43efc
|
@ -883,29 +883,48 @@ static v8::Handle<v8::Value> JS_ExecuteAql (v8::Arguments const& argv) {
|
||||||
|
|
||||||
// bind parameters
|
// bind parameters
|
||||||
TRI_json_t* parameters = nullptr;
|
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.Length() > 1) {
|
||||||
if (! argv[1]->IsObject()) {
|
if (! argv[1]->IsObject()) {
|
||||||
TRI_V8_TYPE_ERROR(scope, "expecting object for <bindvalues>");
|
TRI_V8_TYPE_ERROR(scope, "expecting object for <bindvalues>");
|
||||||
}
|
}
|
||||||
parameters = TRI_ObjectToJson(argv[1]);
|
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 <options>");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO more options . . .
|
v8::Handle<v8::Object> argValue = v8::Handle<v8::Object>::Cast(argv[2]);
|
||||||
if (argv.Length() > 2) {
|
v8::Handle<v8::String> optionName = v8::String::New("batchSize");
|
||||||
// we have options! yikes!
|
|
||||||
if (! argv[2]->IsObject()) {
|
|
||||||
TRI_V8_TYPE_ERROR(scope, "expecting object for <options>");
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::Handle<v8::Object> objValue = v8::Handle<v8::Object>::Cast(argv[2]);
|
if (argValue->Has(optionName)) {
|
||||||
v8::Handle<v8::String> batchSizeName = v8::String::New("batchSize");
|
batchSize = TRI_ObjectToInt64(argValue->Get(optionName));
|
||||||
if (objValue->Has(batchSizeName)) {
|
if (batchSize <= 0) {
|
||||||
batchSize = TRI_ObjectToInt64(objValue->Get(batchSizeName));
|
TRI_V8_TYPE_ERROR(scope, "expecting non-negative integer for <batchSize>");
|
||||||
if (batchSize <= 0) {
|
// well, this makes no sense
|
||||||
TRI_V8_TYPE_ERROR(scope, "expecting non-negative integer for <batchSize>");
|
}
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue