diff --git a/modules/eventing/pages/eventing-language-constructs.adoc b/modules/eventing/pages/eventing-language-constructs.adoc index b20d16b30..432d45ce3 100644 --- a/modules/eventing/pages/eventing-language-constructs.adoc +++ b/modules/eventing/pages/eventing-language-constructs.adoc @@ -15,10 +15,10 @@ Certain capabilities have been removed and are not supported in order to handle Eventing Functions support the following features: -* <> -* <> -* <> -* <> +* <> +* <> +* <> +* <> [#basic_bucket_accessors] === Basic Keyspace Accessors @@ -77,7 +77,7 @@ function OnUpdate(doc, meta) { Advanced Keyspace Accessors expose a larger set of options and operators than <>. They have non-trivial argument sets and return values. -See xref:eventing-advanced-keyspace-accessors.adoc[Advanced Keyspace Accessors] for more details. +See xref:eventing-advanced-keyspace-accessors.adoc[] for more details. [#logging] === Logging @@ -196,10 +196,10 @@ To include comments in multiline statements, use `/* this format */` instead. The following features are not supported by Eventing Functions: -* <> -* <> -* <> -* <> +* <> +* <> +* <> +* <> [#global-state] === Global State @@ -264,13 +264,13 @@ The Eventing Service does not support importing libraries into Eventing Function Eventing Functions support the following built-in functions: -* <> -* <> -* <> -* <> -* <> -* <> -* <> +* <> +* <> +* <> +* <> +* <> +* <> +* <> [#n1ql_call] === `N1QL()` @@ -376,14 +376,13 @@ The `close()` method on the iterable handle can throw an exception if the underl |=== [#analytics_call] -=== `ANALYTICS()` +=== `couchbase.{zwsp}analyticsQuery({wj})` ifeval::['{page-component-version}' == '7.6'] - [.status]#Introduced in Couchbase Server 7.6# endif::[] -The `ANALYTICS()` function provides integration with {sqlpp} Analytics directly from the Eventing Service. +The `couchbase.analyticsQuery()` function provides integration with {sqlpp} Analytics directly from the Eventing Service. Integrating Eventing with Analytics: @@ -391,38 +390,28 @@ Integrating Eventing with Analytics: * Simplifies Eventing code logic and improves code readability * Eliminates security and network latency issues with the `curl()` function +The following example assumes that the Analytics collection (dataset) called `default` already exists. + [source,javascript] ---- function OnUpdate(doc, meta) { - // Ignore information we don't care about - if (doc.type !== 'airline') return; - - // Get the total routes per IATA - var route_cnt = 0; - // Uses a true variable as a SQL++ parameter - var airline = doc.iata; - - var results = ANALYTICS( - "SELECT COUNT(*) AS cnt - FROM `travel-sample`.`inventory`.`route` - WHERE type = \"route\" - AND airline = $1", [doc.iata] - ); - - // Stream results using the 'for' iterator - for (var item of results) { - route_cnt = item.cnt; + var count = 0; + const limit = 4; + + let query = couchbase.analyticsQuery('SELECT * FROM default LIMIT $limit;', { + "limit": limit + }); + for (let row of query) { + ++count; } - // End the query and free the resources held - results.close(); - - // Log the KEY, AIRLINE and ROUTE_CNT - log("key: " + meta.id + ", airline: " + doc.iata + ", route_cnt: " + route_cnt); + if (count === limit) { + dst_bucket[meta.id] = 'yes'; + } } ---- -For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[What’s SQL++ for Analytics?]. +For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[]. [#crc64_call] === `crc64()` @@ -556,14 +545,14 @@ To cancel a Timer, you can do one of the following: * Call the `createTimer()` function again using a reference from the existing Timer you want to cancel. * Call the `cancelTimer()` function using `cancelTimer(callback, reference)`. -For more information about Timers, see xref:eventing-timers.adoc[Timers]. +For more information about Timers, see xref:eventing-timers.adoc[]. [#curl_call] === `curl()` The `curl()` function lets you interact with external entities through a REST endpoint from Eventing Functions, using either HTTP or HTTPS. -For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[cURL]. +For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[]. [#handler-signatures] @@ -571,9 +560,9 @@ For more information about the `curl()` function, see xref:eventing-curl-spec.ad The Eventing Service calls the following JavaScript functions on events like mutations and fired Timers: -* <> -* <> -* <> +* <> +* <> +* <> [#onupdate_handler] === OnUpdate Handler @@ -662,7 +651,7 @@ function OnUpdate(doc, meta) { } ---- -For more information about Timers, see xref:eventing-timers.adoc[Timers]. +For more information about Timers, see xref:eventing-timers.adoc[]. == Reserved Words