Skip to content

Commit 0466c5f

Browse files
authored
Revert "DOC-12533: Feedback on Language Constructs (#297)"
This reverts commit 60bc781.
1 parent 00a84c9 commit 0466c5f

File tree

1 file changed

+49
-38
lines changed

1 file changed

+49
-38
lines changed

modules/eventing/pages/eventing-language-constructs.adoc

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Certain capabilities have been removed and are not supported in order to handle
1515

1616
Eventing Functions support the following features:
1717

18-
* <<basic_bucket_accessors>>
19-
* <<advanced_bucket_accessors>>
20-
* <<logging>>
21-
* <<n1ql_statements>>
18+
* <<basic_bucket_accessors,Basic Keyspace Accessors>>
19+
* <<advanced_bucket_accessors,Advanced Keyspace Accessors>>
20+
* <<logging,Logging>>
21+
* <<n1ql_statements,{sqlpp} Statements>>
2222
2323
[#basic_bucket_accessors]
2424
=== Basic Keyspace Accessors
@@ -77,7 +77,7 @@ function OnUpdate(doc, meta) {
7777
Advanced Keyspace Accessors expose a larger set of options and operators than <<basic_bucket_accessors,Basic Keyspace Accessors>>.
7878
They have non-trivial argument sets and return values.
7979

80-
See xref:eventing-advanced-keyspace-accessors.adoc[] for more details.
80+
See xref:eventing-advanced-keyspace-accessors.adoc[Advanced Keyspace Accessors] for more details.
8181

8282
[#logging]
8383
=== Logging
@@ -198,10 +198,10 @@ To include comments in multiline statements, use `/* this format */` instead.
198198

199199
The following features are not supported by Eventing Functions:
200200

201-
* <<global-state>>
202-
* <<asynchrony>>
203-
* <<browser_extensions>>
204-
* <<library_imports>>
201+
* <<global-state,Global State>>
202+
* <<asynchrony,Asynchrony>>
203+
* <<browser_extensions,Browser and Other Extensions>>
204+
* <<library_imports,Library Imports>>
205205

206206
[#global-state]
207207
=== Global State
@@ -266,13 +266,13 @@ The Eventing Service does not support importing libraries into Eventing Function
266266

267267
Eventing Functions support the following built-in functions:
268268

269-
* <<n1ql_call>>
270-
* <<analytics_call>>
271-
* <<crc64_call>>
272-
* <<crc_64_go_iso_call>>
273-
* <<base64_call>>
274-
* <<timers_general>>
275-
* <<curl_call>>
269+
* <<n1ql_call,`N1QL()`>>
270+
* <<analytics_call,`ANALYTICS()`>>
271+
* <<crc64_call,`crc64()`>>
272+
* <<crc_64_go_iso_call, `crc_64_go_iso()`>>
273+
* <<base64_call,`base64()`>>
274+
* <<timers_general,`createTimer()` and `cancelTimer()`>>
275+
* <<curl_call,`curl()`>>
276276

277277
[#n1ql_call]
278278
=== `N1QL()`
@@ -378,42 +378,53 @@ The `close()` method on the iterable handle can throw an exception if the underl
378378
|===
379379

380380
[#analytics_call]
381-
=== `couchbase.{zwsp}analyticsQuery({wj})`
381+
=== `ANALYTICS()`
382382

383383
ifeval::['{page-component-version}' == '7.6']
384+
384385
[.status]#Introduced in Couchbase Server 7.6#
385386
endif::[]
386387

387-
The `couchbase.analyticsQuery()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
388+
The `ANALYTICS()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
388389

389390
Integrating Eventing with Analytics:
390391

391392
* Allows Eventing to benefit from the high availability and load balancing of Analytics, where requests can take turns being submitted across nodes
392393
* Simplifies Eventing code logic and improves code readability
393394
* Eliminates security and network latency issues with the `curl()` function
394395

395-
The following example assumes that the Analytics collection (dataset) called `default` already exists.
396-
397396
[source,javascript]
398397
----
399398
function OnUpdate(doc, meta) {
400-
var count = 0;
401-
const limit = 4;
402-
403-
let query = couchbase.analyticsQuery('SELECT * FROM default LIMIT $limit;', {
404-
"limit": limit
405-
});
406-
for (let row of query) {
407-
++count;
408-
}
399+
// Ignore information we don't care about
400+
if (doc.type !== 'airline') return;
401+
402+
// Get the total routes per IATA
403+
var route_cnt = 0;
404+
// Uses a true variable as a SQL++ parameter
405+
var airline = doc.iata;
406+
407+
var results = ANALYTICS(
408+
"SELECT COUNT(*) AS cnt
409+
FROM `travel-sample`.`inventory`.`route`
410+
WHERE type = \"route\"
411+
AND airline = $1", [doc.iata]
412+
);
409413
410-
if (count === limit) {
411-
dst_bucket[meta.id] = 'yes';
414+
// Stream results using the 'for' iterator
415+
for (var item of results) {
416+
route_cnt = item.cnt;
412417
}
418+
419+
// End the query and free the resources held
420+
results.close();
421+
422+
// Log the KEY, AIRLINE and ROUTE_CNT
423+
log("key: " + meta.id + ", airline: " + doc.iata + ", route_cnt: " + route_cnt);
413424
}
414425
----
415426

416-
For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[].
427+
For more information about {sqlpp} Analytics, see xref:server:analytics:1_intro.adoc[What’s SQL++ for Analytics?].
417428

418429
[#crc64_call]
419430
=== `crc64()`
@@ -547,24 +558,24 @@ To cancel a Timer, you can do one of the following:
547558
* Call the `createTimer()` function again using a reference from the existing Timer you want to cancel.
548559
* Call the `cancelTimer()` function using `cancelTimer(callback, reference)`.
549560

550-
For more information about Timers, see xref:eventing-timers.adoc[].
561+
For more information about Timers, see xref:eventing-timers.adoc[Timers].
551562

552563
[#curl_call]
553564
=== `curl()`
554565

555566
The `curl()` function lets you interact with external entities through a REST endpoint from Eventing Functions, using either HTTP or HTTPS.
556567

557-
For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[].
568+
For more information about the `curl()` function, see xref:eventing-curl-spec.adoc[cURL].
558569

559570

560571
[#handler-signatures]
561572
== Handler Signatures
562573

563574
The Eventing Service calls the following JavaScript functions on events like mutations and fired Timers:
564575

565-
* <<onupdate_handler>>
566-
* <<ondelete_handler>>
567-
* <<timer_callback_handler>>
576+
* <<onupdate_handler,OnUpdate Handler>>
577+
* <<ondelete_handler,OnDelete Handler>>
578+
* <<timer_callback_handler,Timer Callback Handler>>
568579

569580
[#onupdate_handler]
570581
=== OnUpdate Handler
@@ -653,7 +664,7 @@ function OnUpdate(doc, meta) {
653664
}
654665
----
655666

656-
For more information about Timers, see xref:eventing-timers.adoc[].
667+
For more information about Timers, see xref:eventing-timers.adoc[Timers].
657668

658669

659670
== Reserved Words

0 commit comments

Comments
 (0)