From e712ebd23bfb307fd404638804f435e15a183799 Mon Sep 17 00:00:00 2001 From: Simon Dew Date: Fri, 15 Mar 2024 00:41:51 +0000 Subject: [PATCH 1/2] Update Monitor Queries --- .../pages/monitor/monitoring-n1ql-query.adoc | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/manage/pages/monitor/monitoring-n1ql-query.adoc b/modules/manage/pages/monitor/monitoring-n1ql-query.adoc index a11bf7c71f..4acb4da0cd 100644 --- a/modules/manage/pages/monitor/monitoring-n1ql-query.adoc +++ b/modules/manage/pages/monitor/monitoring-n1ql-query.adoc @@ -2270,22 +2270,26 @@ __optional__ |**text** + __optional__ -|For inline functions only: the verbatim text of the function. +|For inline functions: the verbatim text of the function. + +''' + +For {sqlpp} managed user-defined functions: the external code defining the function. |String |**library** + __optional__ -|For JavaScript functions only: the library containing the function. +|For external functions only: the library containing the function. |String |**name** + __optional__ -|For JavaScript functions only: the relative name of the library. +|For external functions only: the relative name of the library. |String |**object** + __optional__ -|For JavaScript functions only: the object defining the function. +|For external functions only: the object defining the function. |String |=== @@ -2449,17 +2453,21 @@ __optional__ |**text** + __optional__ -|For inline functions only: the verbatim text of the function. +|For inline functions: the verbatim text of the function. + +''' + +For {sqlpp} managed user-defined functions: the external code defining the function. |String |**library** + __optional__ -|For JavaScript functions only: the library containing the function. +|For external functions only: the library containing the function. |String |**object** + __optional__ -|For JavaScript functions only: the object defining the function. +|For external functions only: the object defining the function. |String |**avgServiceTime** + From 5ebb23b235cbca6ee69dbd0244001ea17cc7d183 Mon Sep 17 00:00:00 2001 From: Simon Dew Date: Fri, 15 Mar 2024 10:38:11 +0000 Subject: [PATCH 2/2] Update UDFs UI --- modules/tools/pages/udfs-ui.adoc | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/tools/pages/udfs-ui.adoc b/modules/tools/pages/udfs-ui.adoc index 3bab93ef78..756f354440 100644 --- a/modules/tools/pages/udfs-ui.adoc +++ b/modules/tools/pages/udfs-ui.adoc @@ -5,19 +5,24 @@ [abstract] {description} -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. +Couchbase Administration console provides an interface to create, update, or delete user-defined functions written in {sqlpp} or JavaScript. -Start at the administration console and select menu:Query[UDFs] from the menus to access the *UDF* screen. +Start at the administration console and select menu:Query[UDF] from the menus to access the *UDF* screen. image::udf-screen.png[alt="screen for adding user-defined functions"] -== Javascript Function Libraries +If you have created any external libraries to store external function code, these are listed in the *JavaScript Function Libraries* section. + +If you have created any inline or external user-defined functions, these are listed in the *User-Defined Functions* section. +This includes {sqlpp} managed user-defined functions -- that is, JavaScript functions which are not stored in a library. + +== JavaScript Function Libraries Click on the `{plus}{nbsp}add function library` link to create a library of JavaScript functions. image::udf-add-library.png[,500, alt="add javascript library screen"] -When you create a new library, an example function (`add`) is supplied as an example. +When you create a new library, an example function (`add`) is supplied as an example. You can delete it when you add your own function, or leave it to serve as a basic example. 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:[ image::udf-screen-with-library.png[alt="udf screen with library added"] -You can *edit* the library again to add and/or delete functions contained inside it. +You can *edit* the library again to add and/or delete functions contained inside it. You can also delete the whole library by clicking on the *drop* link. @@ -37,6 +42,11 @@ You can also delete the whole library by clicking on the *drop* link. You can add your own user-defined functions in the lower *User-Defined Functions* list. These functions can be one of two types: +[horizontal] +*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]. + +*JavaScript*:: You can create {sqlpp} functions that call the JavaScript functions defined in your library. + To add a user-defined function, click on *{plus}{nbsp}add function* below the *User-Defined Functions* list. image::udf-add-function-inline.png[,500, alt="Add function screen"] @@ -50,20 +60,19 @@ The name must be unique and is case-insensitive. 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[]`. -The *Function Type* can be either `inline` or `Javascript`: - -[horizontal] -*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]. - -*JavaScript*:: You can create {sqlpp} functions that call the Javascript functions defined in your library. +The *Function Type* can be either `inline` or `javascript`. 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. This is the default when creating a function. -If you switch *Function Type* to `Javascript` then the dialog will change to configure a JavaScript function call. +If you switch *Function Type* to `javascript` then the dialog will change to configure a JavaScript function call. + +image::udf-add-function-js.png[,500, alt="add JavaScript function"] -image::udf-add-function-js.png[,500, alt="add Javascript function"] +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.) -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.) +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. -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. \ No newline at end of file +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. +To do this, see xref:n1ql:n1ql-language-reference/createfunction.adoc[].