1
0
Fork 0

added db._explain() convenience function

This commit is contained in:
Jan Steemann 2015-10-21 12:52:40 +02:00
parent f40cb79040
commit 3396214a63
5 changed files with 50 additions and 0 deletions

View File

@ -827,6 +827,22 @@ ArangoDatabase.prototype._query = function (query, bindVars, cursorOptions, opti
return new ArangoStatement(this, data).execute();
};
////////////////////////////////////////////////////////////////////////////////
/// @brief explains a query
////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._explain = function (query, bindVars, options) {
if (typeof query === 'object' && typeof query.toAQL === 'function') {
query = { query: query.toAQL() };
}
if (arguments.length > 1) {
query = { query: query, bindVars: bindVars, options: options };
}
require("org/arangodb/aql/explainer").explain(query);
};
// -----------------------------------------------------------------------------
// --SECTION-- database functions
// -----------------------------------------------------------------------------

View File

@ -129,6 +129,7 @@ exports.HELP = exports.createHelpHeadline("Help") +
'Examples: ' + "\n" +
' > db._collections() list all collections ' + "\n" +
' > db._query(<query>).toArray() execute an AQL query ' + "\n" +
' > db._explain(<query>) explain an AQL query ' + "\n" +
' > help show help pages ' + "\n" +
' > exit ' + "\n" +
'Note: collection names and statuses may be cached in arangosh. ' + "\n" +

View File

@ -826,6 +826,22 @@ ArangoDatabase.prototype._query = function (query, bindVars, cursorOptions, opti
return new ArangoStatement(this, data).execute();
};
////////////////////////////////////////////////////////////////////////////////
/// @brief explains a query
////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._explain = function (query, bindVars, options) {
if (typeof query === 'object' && typeof query.toAQL === 'function') {
query = { query: query.toAQL() };
}
if (arguments.length > 1) {
query = { query: query, bindVars: bindVars, options: options };
}
require("org/arangodb/aql/explainer").explain(query);
};
// -----------------------------------------------------------------------------
// --SECTION-- database functions
// -----------------------------------------------------------------------------

View File

@ -128,6 +128,7 @@ exports.HELP = exports.createHelpHeadline("Help") +
'Examples: ' + "\n" +
' > db._collections() list all collections ' + "\n" +
' > db._query(<query>).toArray() execute an AQL query ' + "\n" +
' > db._explain(<query>) explain an AQL query ' + "\n" +
' > help show help pages ' + "\n" +
' > exit ' + "\n" +
'Note: collection names and statuses may be cached in arangosh. ' + "\n" +

View File

@ -106,6 +106,22 @@ ArangoDatabase.prototype._query = function (query, bindVars, cursorOptions, opti
return new ArangoStatement(this, payload).execute();
};
////////////////////////////////////////////////////////////////////////////////
/// @brief explains a query
////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._explain = function (query, bindVars, options) {
if (typeof query === 'object' && typeof query.toAQL === 'function') {
query = { query: query.toAQL() };
}
if (arguments.length > 1) {
query = { query: query, bindVars: bindVars, options: options };
}
require("org/arangodb/aql/explainer").explain(query);
};
// -----------------------------------------------------------------------------
// --SECTION-- transactions
// -----------------------------------------------------------------------------