mirror of https://gitee.com/bigwinds/arangodb
added collections() function
This commit is contained in:
parent
9c2453a01c
commit
6a75b8affd
|
@ -385,6 +385,7 @@ TRI_associative_pointer_t* TRI_InitialiseFunctionsAql (void) {
|
|||
// misc functions
|
||||
REGISTER_FUNCTION("FAIL", "FAIL", false, false, "|s"); // FAIL is non-deterministic, otherwise query optimisation will fail!
|
||||
REGISTER_FUNCTION("PASSTHRU", "PASSTHRU", false, false, "."); // simple non-deterministic wrapper to avoid optimisations at parse time
|
||||
REGISTER_FUNCTION("COLLECTIONS", "COLLECTIONS", false, false, "");
|
||||
|
||||
REGISTER_FUNCTION("MERGE", "MERGE", true, false, "a,a|+");
|
||||
|
||||
|
|
|
@ -445,6 +445,20 @@ function AHUACATL_GET_DOCUMENTS_SKIPLIST_LIST (collection, idx, attribute, value
|
|||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get names of all collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AHUACATL_COLLECTIONS () {
|
||||
var collections = internal.db._collections();
|
||||
var result = [ ];
|
||||
|
||||
for (var i = 0; i < collections.length; ++i) {
|
||||
result.push({ "_id" : collections[i]._id, "name" : collections[i].name() });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
|
|
|
@ -443,10 +443,23 @@ static string JS_server_ahuacatl =
|
|||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief get names of all collections\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"function AHUACATL_COLLECTIONS () {\n"
|
||||
" var collections = internal.db._collections();\n"
|
||||
" var result = [ ];\n"
|
||||
"\n"
|
||||
" for (var i = 0; i < collections.length; ++i) {\n"
|
||||
" result.push({ \"_id\" : collections[i]._id, \"name\" : collections[i].name() });\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @}\n"
|
||||
|
|
Loading…
Reference in New Issue