mirror of https://gitee.com/bigwinds/arangodb
added db._explain() convenience function
This commit is contained in:
parent
f40cb79040
commit
3396214a63
|
@ -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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -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" +
|
||||
|
|
|
@ -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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -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" +
|
||||
|
|
|
@ -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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue