1
0
Fork 0

added collections() function

This commit is contained in:
Jan Steemann 2012-05-22 13:09:36 +02:00
parent 9c2453a01c
commit 6a75b8affd
3 changed files with 29 additions and 1 deletions

View File

@ -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|+");

View File

@ -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;
}
////////////////////////////////////////////////////////////////////////////////
/// @}

View File

@ -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"