diff --git a/Ahuacatl/ahuacatl-functions.c b/Ahuacatl/ahuacatl-functions.c index ff379d3171..0f7418e734 100644 --- a/Ahuacatl/ahuacatl-functions.c +++ b/Ahuacatl/ahuacatl-functions.c @@ -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|+"); diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js index 91f246aab8..d7d49fda67 100644 --- a/js/server/ahuacatl.js +++ b/js/server/ahuacatl.js @@ -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; +} //////////////////////////////////////////////////////////////////////////////// /// @} diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h index c5d48e3730..00eb9c3ac3 100644 --- a/js/server/js-ahuacatl.h +++ b/js/server/js-ahuacatl.h @@ -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"