You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/eventing/pages/eventing-language-constructs.adoc
+52-13Lines changed: 52 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ Replaces any existing value with the specified key.
52
52
This operation throws an exception if the underlying bucket SET operation fails with an unexpected error.
53
53
54
54
|DELETE
55
-
|`operator[]` appears afer the JavaScript delete keyword.
55
+
|`operator[]` appears after the JavaScript delete keyword.
56
56
57
57
Deletes the provided key from the KV bucket that the variable is bound to.
58
58
Returns a no-op if the object does not exist.
@@ -109,7 +109,7 @@ These operations are accessible through the returned iterable handle.
109
109
{sqlpp} Query results, through the SELECT operation, are streamed in batches to the iterable handle as the iteration progresses through the result set.
110
110
111
111
NOTE: To avoid recursion, an Eventing Function can listen for mutations in a bucket.
112
-
{sqlpp} DML statements canot manipulate documents in that same bucket.
112
+
{sqlpp} DML statements cannot manipulate documents in that same bucket.
113
113
To work around this, you can use the exposed data service KV map in your Eventing Function.
114
114
115
115
The following Function has a feed boundary of *Everything*, which means the same {sqlpp} statement is executed 7,303 times.
@@ -196,7 +196,7 @@ To include comments in multiline statements, use `/* this format */` instead.
196
196
197
197
The following features are not supported by Eventing Functions:
198
198
199
-
* <<global_state,Global State>>
199
+
* <<global-state,Global State>>
200
200
* <<asynchrony,Asynchrony>>
201
201
* <<browser_extensions,Browser and Other Extensions>>
202
202
* <<library_imports,Library Imports>>
@@ -227,7 +227,7 @@ For example, a Constant alias of `debug` with a value of `true` or `false` behav
227
227
Eventing Functions do not support asynchronous flows.
228
228
229
229
Asynchrony creates a node-specific, long-running state that prevents persistence providers from capturing the entire state.
230
-
This limits Eventing Functions to execute short-running, straight-line code without sleep and wakeups.
230
+
This limits Eventing Functions to executing short-running, straight-line code without sleep and wake-ups.
231
231
232
232
You can use Timers to add limited asynchrony back into your Function.
233
233
Timers are designed specifically to prevent a state from being node-specific.
@@ -267,6 +267,7 @@ Eventing Functions support the following built-in functions:
267
267
* <<n1ql_call,`N1QL()`>>
268
268
* <<analytics_call,`ANALYTICS()`>>
269
269
* <<crc64_call,`crc64()`>>
270
+
* <<crc_64_go_iso_call, `crc_64_go_iso()`>>
270
271
* <<base64_call,`base64()`>>
271
272
* <<timers_general,`createTimer()` and `cancelTimer()`>>
272
273
* <<curl_call,`curl()`>>
@@ -290,7 +291,7 @@ The `N1QL()` function contains the following parameters:
290
291
|The identified {sqlpp} statement.
291
292
This is passed to {sqlpp} through SDK to run as a prepared statement.
292
293
293
-
All of the JavaScript variables referenced in the statement using the `$<variable>` notation are treated as named parameters.
294
+
All the JavaScript variables referenced in the statement using the `$<variable>` notation are treated as named parameters.
294
295
295
296
|`params`
296
297
a|Can be a JavaScript array or a JavaScript map object.
@@ -377,6 +378,11 @@ The `close()` method on the iterable handle can throw an exception if the underl
377
378
[#analytics_call]
378
379
=== `ANALYTICS()`
379
380
381
+
ifeval::['{page-component-version}' == '7.6']
382
+
383
+
[.status]#Introduced in Couchbase Server 7.6#
384
+
endif::[]
385
+
380
386
The `ANALYTICS()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
381
387
382
388
Integrating Eventing with Analytics:
@@ -430,7 +436,7 @@ The `crc64()` function takes the object to checksum as its only parameter.
430
436
The parameter can be any JavaScript object that can be encoded to JSON.
431
437
432
438
The function returns the hash as a string.
433
-
The hash is sensitive to the order of the parameters in case of map objects.
439
+
The hash is sensitive to the order of the parameters in the case of map objects.
434
440
435
441
If multiple Eventing Functions share the same `crc64` checksum documents as the Sync Gateway, real mutations can be suppressed and missed.
436
442
To prevent this from happening, you can make the checksum documents unique to each Eventing Function.
@@ -464,10 +470,43 @@ function OnUpdate(doc, meta) {
464
470
// Business logic goes in here
465
471
}
466
472
----
473
+
.Translating strings
474
+
[NOTE]
475
+
====
476
+
Bear in mind that using `crc64()` to convert strings will include any quotation marks as part of the conversion.
477
+
If you want to translate the string [.underline]#without# including the enclosing quotes, then use the <<crc_64_go_iso_call, `crc_64_go_iso()`>> instead.
478
+
479
+
This does not apply to any other data type (e.g., numeric data or JSON data types).
480
+
====
481
+
482
+
[#crc_64_go_iso_call]
483
+
=== `crc_64_go_iso()`
484
+
485
+
ifeval::['{page-component-version}' == '7.6']
486
+
[.status]#Introduced in Couchbase Server 7.6#
487
+
endif::[]
488
+
489
+
`crc_64_go_iso()` performs the same function as <<crc64_call,`crc64()`>>, but does not include the enclosing quotation marks from the parameter in the translation if its parameter type is `string`.
490
+
491
+
Other datatypes work the same as the `crc64()` call.
492
+
493
+
494
+
[source,javascript]
495
+
----
496
+
function OnUpdate(doc, meta) {
497
+
var crc_iso_str = couchbase.crc_64_go_iso(doc);
498
+
/// Code goes here
499
+
}
500
+
----
501
+
467
502
468
503
[#base64_call]
469
504
=== `base64()`
470
505
506
+
ifeval::['{page-component-version}' == '7.6']
507
+
[.status]#Introduced in Couchbase Server 7.6#
508
+
endif::[]
509
+
471
510
The `base64()` functions let you pack large-dimensional arrays of floats as base64 encoded strings when you use the Eventing Service to generate vector embeddings.
472
511
This encoding process stores and transmits arrays as text, ensuring data integrity and compatibility with text-based systems.
473
512
@@ -478,7 +517,7 @@ The following `base64()` functions are available:
478
517
[source,javascript]
479
518
----
480
519
function OnUpdate(doc, meta) {
481
-
var base_str = base64Encode(doc);
520
+
var base_str = couchbase.base64Encode(doc);
482
521
/// Code goes here
483
522
}
484
523
----
@@ -488,20 +527,20 @@ function OnUpdate(doc, meta) {
488
527
[source,javascript]
489
528
----
490
529
function OnUpdate(doc, meta) {
491
-
var base_str = base64Decode(doc);
530
+
var base_str = couchbase.base64Decode(doc);
492
531
/// Code goes here
493
532
}
494
533
----
495
534
+
496
-
* `base64Float32ArrayEncode()`, which takes a float32 number array and returns a base64 string.
497
-
* `base64Float32ArrayDecode()`, which takes a base64 encoded string and returns a float32 number array.
498
-
* `base64Float64ArrayEncode()`, which takes a float64 number array and returns a base64 string.
499
-
* `base64Float64ArrayDecode()`, which takes a base64 encoded string and returns a float64 number array.
535
+
* `couchbase.base64Float32ArrayEncode()`, which takes a float32 number array and returns a base64 string.
536
+
* `couchbase.base64Float32ArrayDecode()`, which takes a base64 encoded string and returns a float32 number array.
537
+
* `couchbase.base64Float64ArrayEncode()`, which takes a float64 number array and returns a base64 string.
538
+
* `couchbase.base64Float64ArrayDecode()`, which takes a base64 encoded string and returns a float64 number array.
500
539
501
540
[#timers_general]
502
541
=== `createTimer()` and `cancelTimer()`
503
542
504
-
Timers are asynchronous compute.
543
+
Timers are asynchronously computed.
505
544
They allow Eventing Functions to execute in reference to wall-clock events.
0 commit comments