@@ -15,10 +15,10 @@ Certain capabilities have been removed and are not supported in order to handle
1515
1616Eventing Functions support the following features:
1717
18- * <<basic_bucket_accessors,Basic Keyspace Accessors >>
19- * <<advanced_bucket_accessors,Advanced Keyspace Accessors >>
20- * <<logging,Logging >>
21- * <<n1ql_statements,{sqlpp} Statements >>
18+ * <<basic_bucket_accessors>>
19+ * <<advanced_bucket_accessors>>
20+ * <<logging>>
21+ * <<n1ql_statements>>
2222
2323 [#basic_bucket_accessors]
2424=== Basic Keyspace Accessors
@@ -77,7 +77,7 @@ function OnUpdate(doc, meta) {
7777Advanced Keyspace Accessors expose a larger set of options and operators than <<basic_bucket_accessors,Basic Keyspace Accessors>>.
7878They have non-trivial argument sets and return values.
7979
80- See xref:eventing-advanced-keyspace-accessors.adoc[Advanced Keyspace Accessors ] for more details.
80+ See xref:eventing-advanced-keyspace-accessors.adoc[] for more details.
8181
8282[#logging]
8383=== Logging
@@ -196,10 +196,10 @@ To include comments in multiline statements, use `/* this format */` instead.
196196
197197The following features are not supported by Eventing Functions:
198198
199- * <<global-state,Global State >>
200- * <<asynchrony,Asynchrony >>
201- * <<browser_extensions,Browser and Other Extensions >>
202- * <<library_imports,Library Imports >>
199+ * <<global-state>>
200+ * <<asynchrony>>
201+ * <<browser_extensions>>
202+ * <<library_imports>>
203203
204204[#global-state]
205205=== Global State
@@ -264,13 +264,13 @@ The Eventing Service does not support importing libraries into Eventing Function
264264
265265Eventing Functions support the following built-in functions:
266266
267- * <<n1ql_call,`N1QL()` >>
268- * <<analytics_call,`ANALYTICS()` >>
269- * <<crc64_call,`crc64()` >>
270- * <<crc_64_go_iso_call, `crc_64_go_iso()` >>
271- * <<base64_call,`base64()` >>
272- * <<timers_general,`createTimer()` and `cancelTimer()` >>
273- * <<curl_call,`curl()` >>
267+ * <<n1ql_call>>
268+ * <<analytics_call>>
269+ * <<crc64_call>>
270+ * <<crc_64_go_iso_call>>
271+ * <<base64_call>>
272+ * <<timers_general>>
273+ * <<curl_call>>
274274
275275[#n1ql_call]
276276=== `N1QL()`
@@ -376,53 +376,42 @@ The `close()` method on the iterable handle can throw an exception if the underl
376376|===
377377
378378[#analytics_call]
379- === `ANALYTICS( )`
379+ === `couchbase.{zwsp}analyticsQuery({wj} )`
380380
381381ifeval::['{page-component-version}' == '7.6']
382-
383382[.status]#Introduced in Couchbase Server 7.6#
384383endif::[]
385384
386- The `ANALYTICS ()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
385+ The `couchbase.analyticsQuery ()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
387386
388387Integrating Eventing with Analytics:
389388
390389* Allows Eventing to benefit from the high availability and load balancing of Analytics, where requests can take turns being submitted across nodes
391390* Simplifies Eventing code logic and improves code readability
392391* Eliminates security and network latency issues with the `curl()` function
393392
393+ The following example assumes that the Analytics collection (dataset) called `default` already exists.
394+
394395[source,javascript]
395396----
396397function OnUpdate(doc, meta) {
397- // Ignore information we don't care about
398- if (doc.type !== 'airline') return;
399-
400- // Get the total routes per IATA
401- var route_cnt = 0;
402- // Uses a true variable as a SQL++ parameter
403- var airline = doc.iata;
404-
405- var results = ANALYTICS(
406- "SELECT COUNT(*) AS cnt
407- FROM `travel-sample`.`inventory`.`route`
408- WHERE type = \"route\"
409- AND airline = $1", [doc.iata]
410- );
411-
412- // Stream results using the 'for' iterator
413- for (var item of results) {
414- route_cnt = item.cnt;
398+ var count = 0;
399+ const limit = 4;
400+
401+ let query = couchbase.analyticsQuery('SELECT * FROM default LIMIT $limit;', {
402+ "limit": limit
403+ });
404+ for (let row of query) {
405+ ++count;
415406 }
416407
417- // End the query and free the resources held
418- results.close();
419-
420- // Log the KEY, AIRLINE and ROUTE_CNT
421- log("key: " + meta.id + ", airline: " + doc.iata + ", route_cnt: " + route_cnt);
408+ if (count === limit) {
409+ dst_bucket[meta.id] = 'yes';
410+ }
422411}
423412----
424413
425- For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[What’s SQL++ for Analytics? ].
414+ For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[].
426415
427416[#crc64_call]
428417=== `crc64()`
@@ -556,24 +545,24 @@ To cancel a Timer, you can do one of the following:
556545* Call the `createTimer()` function again using a reference from the existing Timer you want to cancel.
557546* Call the `cancelTimer()` function using `cancelTimer(callback, reference)`.
558547
559- For more information about Timers, see xref:eventing-timers.adoc[Timers ].
548+ For more information about Timers, see xref:eventing-timers.adoc[].
560549
561550[#curl_call]
562551=== `curl()`
563552
564553The `curl()` function lets you interact with external entities through a REST endpoint from Eventing Functions, using either HTTP or HTTPS.
565554
566- For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[cURL ].
555+ For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[].
567556
568557
569558[#handler-signatures]
570559== Handler Signatures
571560
572561The Eventing Service calls the following JavaScript functions on events like mutations and fired Timers:
573562
574- * <<onupdate_handler,OnUpdate Handler >>
575- * <<ondelete_handler,OnDelete Handler >>
576- * <<timer_callback_handler,Timer Callback Handler >>
563+ * <<onupdate_handler>>
564+ * <<ondelete_handler>>
565+ * <<timer_callback_handler>>
577566
578567[#onupdate_handler]
579568=== OnUpdate Handler
@@ -662,7 +651,7 @@ function OnUpdate(doc, meta) {
662651}
663652----
664653
665- For more information about Timers, see xref:eventing-timers.adoc[Timers ].
654+ For more information about Timers, see xref:eventing-timers.adoc[].
666655
667656
668657== Reserved Words
0 commit comments