1
0
Fork 0

fixed examples, removed parameter info

This commit is contained in:
Frank Celler 2012-03-28 18:19:54 +02:00
parent 2b7393eb6e
commit 304aadbb4b
8 changed files with 327 additions and 12 deletions

View File

@ -6,10 +6,8 @@ content-type: application/json
{
"name": "UnitTestsCollectionBasics",
"code": 200,
"waitForSync": true,
"id": 55144253,
"count": 0,
"journalSize": 32664,
"status": 3,
"error": false
}

View File

@ -224,6 +224,8 @@ JAVASCRIPT_HEADER = \
js/common/bootstrap/js-errors.h \
js/client/js-client.h \
js/server/js-aql-operators.h \
js/server/js-aql-functions-numeric.h \
js/server/js-aql-functions-string.h \
js/server/js-server.h
BUILT_SOURCES += $(JAVASCRIPT_HEADER)

View File

@ -771,6 +771,8 @@ JAVASCRIPT_HEADER = \
js/common/bootstrap/js-errors.h \
js/client/js-client.h \
js/server/js-aql-operators.h \
js/server/js-aql-functions-numeric.h \
js/server/js-aql-functions-string.h \
js/server/js-server.h

View File

@ -316,7 +316,6 @@ describe AvocadoDB do
doc.parsed_response['id'].should eq(cid)
doc.parsed_response['name'].should eq(@cn)
doc.parsed_response['status'].should eq(3)
doc.parsed_response['waitForSync'].should == true
doc.parsed_response['count'].should be_kind_of(Integer)
doc.headers['content-type'].should eq("application/json")
@ -336,7 +335,6 @@ describe AvocadoDB do
doc.parsed_response['id'].should eq(cid)
doc.parsed_response['name'].should eq(@cn)
doc.parsed_response['status'].should eq(3)
doc.parsed_response['waitForSync'].should == true
doc.parsed_response['count'].should be_kind_of(Integer)
doc.headers['content-type'].should eq("application/json")

View File

@ -383,7 +383,7 @@ function PUT_api_collection_load (req, res, collection) {
try {
collection.load();
var result = CollectionRepresentation(collection, true, true, false);
var result = CollectionRepresentation(collection, false, true, false);
actions.resultOk(req, res, actions.HTTP_OK, result);
}

View File

@ -0,0 +1,165 @@
static string JS_server_aql_functions_numeric =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief AQL query language numeric functions\n"
"///\n"
"/// @file\n"
"///\n"
"/// DISCLAIMER\n"
"///\n"
"/// Copyright 2010-2012 triagens GmbH, Cologne, Germany\n"
"///\n"
"/// Licensed under the Apache License, Version 2.0 (the \"License\");\n"
"/// you may not use this file except in compliance with the License.\n"
"/// You may obtain a copy of the License at\n"
"///\n"
"/// http://www.apache.org/licenses/LICENSE-2.0\n"
"///\n"
"/// Unless required by applicable law or agreed to in writing, software\n"
"/// distributed under the License is distributed on an \"AS IS\" BASIS,\n"
"/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
"/// See the License for the specific language governing permissions and\n"
"/// limitations under the License.\n"
"///\n"
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
"///\n"
"/// @author Jan Steemann\n"
"/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief integer closest to value, not greater than value\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_FLOOR (value) {\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" \n"
" return Math.floor(value);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief integer closest to value and not less than value\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_CEIL (value) {\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" \n"
" return Math.ceil(value);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief integer closest to value \n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_ROUND (value) {\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" \n"
" return Math.round(value);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief absolute value\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_ABS (value) {\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" \n"
" return Math.abs(value);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief minimum of all values, ignores undefined\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_MIN_WU () {\n"
" var result = undefined;\n"
"\n"
" for (var i in arguments) {\n"
" var value = arguments[i];\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" continue;\n"
" }\n"
" if (result === undefined || value < result) {\n"
" result = value;\n"
" }\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief maximum of all values, ignores undefined\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_MAX_WU () {\n"
" var result = undefined;\n"
"\n"
" for (var i in arguments) {\n"
" var value = arguments[i];\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" continue;\n"
" }\n"
" if (result === undefined || value > result) {\n"
" result = value;\n"
" }\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief minimum of all values\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_MIN () {\n"
" var result = undefined;\n"
"\n"
" for (var i in arguments) {\n"
" var value = arguments[i];\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" if (result === undefined || value < result) {\n"
" result = value;\n"
" }\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief maximum of all values\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_MAX () {\n"
" var result = undefined;\n"
"\n"
" for (var i in arguments) {\n"
" var value = arguments[i];\n"
" if (!AQL_IS_NUMBER(value)) {\n"
" return undefined;\n"
" }\n"
" if (result === undefined || value > result) {\n"
" result = value;\n"
" }\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief a random value between 0 and 1\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_NUMBER_RAND () {\n"
" return Math.random();\n"
"}\n"
"\n"
;

View File

@ -0,0 +1,150 @@
static string JS_server_aql_functions_string =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief AQL query language string functions\n"
"///\n"
"/// @file\n"
"///\n"
"/// DISCLAIMER\n"
"///\n"
"/// Copyright 2010-2012 triagens GmbH, Cologne, Germany\n"
"///\n"
"/// Licensed under the Apache License, Version 2.0 (the \"License\");\n"
"/// you may not use this file except in compliance with the License.\n"
"/// You may obtain a copy of the License at\n"
"///\n"
"/// http://www.apache.org/licenses/LICENSE-2.0\n"
"///\n"
"/// Unless required by applicable law or agreed to in writing, software\n"
"/// distributed under the License is distributed on an \"AS IS\" BASIS,\n"
"/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
"/// See the License for the specific language governing permissions and\n"
"/// limitations under the License.\n"
"///\n"
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
"///\n"
"/// @author Jan Steemann\n"
"/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the length of the string in number of characters\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_LENGTH (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.length;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns a substring from the original string\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_SUBSTRING (value, start, length) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_NUMBER(start)) {\n"
" return undefined;\n"
" }\n"
"\n"
" if (length === undefined) {\n"
" return value.substr(start);\n"
" }\n"
"\n"
" if (!AQL_IS_NUMBER(length) || length < 0) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.substr(start, length);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the string in upper case\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_UPPER (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.toUpperCase();\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the string in lower case\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_LOWER (value) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" return value.toLowerCase();\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns the position of substring search in value\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_POSITION (value, search, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" var result = value.search(new RegExp(search), args);\n"
" if (result === -1) {\n"
" return undefined;\n"
" }\n"
"\n"
" return result;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief returns whether value contains the substring search\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_CONTAINS (value, search, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" return (value.search(new RegExp(search), args) !== -1);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief replaces pattern in value with replace\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"function AQL_STRING_REPLACE (value, pattern, replace, insensitive) {\n"
" if (!AQL_IS_STRING(value)) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_STRING(pattern) || pattern.length == 0) {\n"
" return undefined;\n"
" }\n"
" if (!AQL_IS_STRING(replace)) {\n"
" return undefined;\n"
" }\n"
"\n"
" var args = \"g\";\n"
" if (insensitive) {\n"
" args += \"i\";\n"
" }\n"
"\n"
" return value.replace(new RegExp(pattern, args), replace);\n"
"}\n"
"\n"
;

View File

@ -26,13 +26,13 @@ static string JS_server_aql_operators =
"/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"var AQL_TYPEWEIGHT_UNDEFINED = 0;\n"
"var AQL_TYPEWEIGHT_NULL = 1;\n"
"var AQL_TYPEWEIGHT_BOOL = 2;\n"
"var AQL_TYPEWEIGHT_NUMBER = 3;\n"
"var AQL_TYPEWEIGHT_STRING = 4;\n"
"var AQL_TYPEWEIGHT_ARRAY = 5;\n"
"var AQL_TYPEWEIGHT_OBJECT = 6;\n"
"var AQL_TYPEWEIGHT_UNDEFINED = 1;\n"
"var AQL_TYPEWEIGHT_NULL = 2;\n"
"var AQL_TYPEWEIGHT_BOOL = 4;\n"
"var AQL_TYPEWEIGHT_NUMBER = 8;\n"
"var AQL_TYPEWEIGHT_STRING = 16;\n"
"var AQL_TYPEWEIGHT_ARRAY = 32;\n"
"var AQL_TYPEWEIGHT_OBJECT = 64;\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief return the numeric value or undefined if it is out of range\n"