Skip to content

Commit 0d6fb00

Browse files
authored
DOC-11704: SQL++ managed Javascript UDFs (#3520)
* Update Monitor Queries * Update UDFs UI
1 parent 45a1cc5 commit 0d6fb00

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

modules/manage/pages/monitor/monitoring-n1ql-query.adoc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,22 +2270,26 @@ __optional__
22702270

22712271
|**text** +
22722272
__optional__
2273-
|For inline functions only: the verbatim text of the function.
2273+
|For inline functions: the verbatim text of the function.
2274+
2275+
'''
2276+
2277+
For {sqlpp} managed user-defined functions: the external code defining the function.
22742278
|String
22752279

22762280
|**library** +
22772281
__optional__
2278-
|For JavaScript functions only: the library containing the function.
2282+
|For external functions only: the library containing the function.
22792283
|String
22802284

22812285
|**name** +
22822286
__optional__
2283-
|For JavaScript functions only: the relative name of the library.
2287+
|For external functions only: the relative name of the library.
22842288
|String
22852289

22862290
|**object** +
22872291
__optional__
2288-
|For JavaScript functions only: the object defining the function.
2292+
|For external functions only: the object defining the function.
22892293
|String
22902294
|===
22912295

@@ -2449,17 +2453,21 @@ __optional__
24492453

24502454
|**text** +
24512455
__optional__
2452-
|For inline functions only: the verbatim text of the function.
2456+
|For inline functions: the verbatim text of the function.
2457+
2458+
'''
2459+
2460+
For {sqlpp} managed user-defined functions: the external code defining the function.
24532461
|String
24542462

24552463
|**library** +
24562464
__optional__
2457-
|For JavaScript functions only: the library containing the function.
2465+
|For external functions only: the library containing the function.
24582466
|String
24592467

24602468
|**object** +
24612469
__optional__
2462-
|For JavaScript functions only: the object defining the function.
2470+
|For external functions only: the object defining the function.
24632471
|String
24642472

24652473
|**avgServiceTime** +

modules/tools/pages/udfs-ui.adoc

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55
[abstract]
66
{description}
77

8-
Starting from Couchbase Server 7.1, the Couchbase Administration console provides an interface to create, update, or delete user-defined functions written in {sqlpp} or JavaScript.
8+
Couchbase Administration console provides an interface to create, update, or delete user-defined functions written in {sqlpp} or JavaScript.
99

10-
Start at the administration console and select menu:Query[UDFs] from the menus to access the *UDF* screen.
10+
Start at the administration console and select menu:Query[UDF] from the menus to access the *UDF* screen.
1111

1212
image::udf-screen.png[alt="screen for adding user-defined functions"]
1313

14-
== Javascript Function Libraries
14+
If you have created any external libraries to store external function code, these are listed in the *JavaScript Function Libraries* section.
15+
16+
If you have created any inline or external user-defined functions, these are listed in the *User-Defined Functions* section.
17+
This includes {sqlpp} managed user-defined functions -- that is, JavaScript functions which are not stored in a library.
18+
19+
== JavaScript Function Libraries
1520

1621
Click on the `{plus}{nbsp}add function library` link to create a library of JavaScript functions.
1722

1823
image::udf-add-library.png[,500, alt="add javascript library screen"]
1924

20-
When you create a new library, an example function (`add`) is supplied as an example.
25+
When you create a new library, an example function (`add`) is supplied as an example.
2126
You can delete it when you add your own function, or leave it to serve as a basic example.
2227

2328
You can set a *Namespace* for your library which will restrict its access to users that have permissions to access the bucket and scope specified by the namespace.
@@ -28,7 +33,7 @@ Click btn:[Save] to save the library and return to the main UDF screen, or btn:[
2833

2934
image::udf-screen-with-library.png[alt="udf screen with library added"]
3035

31-
You can *edit* the library again to add and/or delete functions contained inside it.
36+
You can *edit* the library again to add and/or delete functions contained inside it.
3237

3338
You can also delete the whole library by clicking on the *drop* link.
3439

@@ -37,6 +42,11 @@ You can also delete the whole library by clicking on the *drop* link.
3742
You can add your own user-defined functions in the lower *User-Defined Functions* list.
3843
These functions can be one of two types:
3944

45+
[horizontal]
46+
*Inline*:: This is a function written in {sqlpp} which can be used as part of another {sqlpp} statement, such as xref:n1ql:n1ql-language-reference/selectintro.adoc[SELECT] and xref:n1ql:n1ql-language-reference/execfunction.adoc[EXECUTE FUNCTION].
47+
48+
*JavaScript*:: You can create {sqlpp} functions that call the JavaScript functions defined in your library.
49+
4050
To add a user-defined function, click on *{plus}{nbsp}add function* below the *User-Defined Functions* list.
4151

4252
image::udf-add-function-inline.png[,500, alt="Add function screen"]
@@ -50,20 +60,19 @@ The name must be unique and is case-insensitive.
5060

5161
You can define a list of fixed parameters for your function, or you can use the `...` symbol which indicates a variable length function list defined as `args[]`.
5262

53-
The *Function Type* can be either `inline` or `Javascript`:
54-
55-
[horizontal]
56-
*Inline*:: This is a function written in {sqlpp} which can be used as part of another {sqlpp} statement, such as xref:n1ql:n1ql-language-reference/selectintro.adoc[SELECT] and xref:n1ql:n1ql-language-reference/execfunction.adoc[EXECUTE FUNCTION].
57-
58-
*JavaScript*:: You can create {sqlpp} functions that call the Javascript functions defined in your library.
63+
The *Function Type* can be either `inline` or `javascript`.
5964

6065
If you are defining an `inline` function then you can fill in any valid {sqlpp} expression which can then be used as part of another {sqlpp} statement.
6166
This is the default when creating a function.
6267

63-
If you switch *Function Type* to `Javascript` then the dialog will change to configure a JavaScript function call.
68+
If you switch *Function Type* to `javascript` then the dialog will change to configure a JavaScript function call.
69+
70+
image::udf-add-function-js.png[,500, alt="add JavaScript function"]
6471

65-
image::udf-add-function-js.png[,500, alt="add Javascript function"]
72+
Then you select the JavaScript Library where you created your JavaScript function, and the name of your function.
73+
(There is no need to include the parameters.)
6674

67-
Then you select the `Javascript Library` where you created your Javascript function, and the name of your function. (There is no need to include the parameters.)
75+
Once the details have been filled, you can click the btn:[Save Function] to save the function and exit the dialog, or click on btn:[Cancel] to exit the dialog without saving the details.
6876

69-
Once the details have been filled, you can click the btn:[Save Function] to save the function and exit the dialog, or click on btn:[Cancel] to exit the dialog without saving the details.
77+
NOTE: You cannot use the UDF console to create {sqlpp} managed user-defined functions -- that is, JavaScript functions which are not stored in a library.
78+
To do this, see xref:n1ql:n1ql-language-reference/createfunction.adoc[].

0 commit comments

Comments
 (0)