Description
Add a new type of javascript user defined function :
- CREATE FUNCTION doc page
https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/createfunction.html
- Javascript UDFs with Couchbase:
https://docs.couchbase.com/server/current/javascript-udfs/javascript-functions-with-couchbase.html
And any other doc pages necessary.
N1QL Managed Javascript Functions
Allows users to create a Javascript function and its corresponding N1QL function in a single statement.
There is a one to one relationship between the Javascript function and the N1QL UDF.
Edit:
- In N1QL managed JS UDFs the library of javascript code is specified inline along with the SQL++ function creation.
- Functions defined in this inline library of javascript code can only be invoked/ referenced within this library.
And cannot be accessed in other libraries.
- Note that: All the RBAC pre-requisites, constraints on allowed Javascript constructs, SQL++ invocation methods - are the same for both the existing external JS UDFs and the new N1QL managed JS UDFs.
Syntax
create-function-query-managed-javascript ::=
|
'CREATE' ( 'OR' 'REPLACE' )? 'FUNCTION' function '(' params? ')' |
( 'IF' 'NOT' 'EXISTS' )? |
'LANGUAGE' 'JAVASCRIPT' 'AS' javascript-code |
Function : function name
Params : function parameters
Javascript-code : A string that contains Javascript code. It must contain a function definition with the SAME name as the corresponding N1QL function.
The javascript-code can contain multiple function definitions. But these functions can only be referenced within this N1QL function and cannot be shared.
Example:
Create N1QL managed JS UDF:
CREATE FUNCTION func1() LANGUAGE JAVASCRIPT AS "function func1(param1) { return param1+100;}”; |
Execute the function:
EXECUTE FUNCTION func1(100); |
[
|
200 |
]
|
Attachments
Issue Links
- mentioned in
-
Page Loading...