Skip to content

Commit 0f9c608

Browse files
RayOffiahsarahlwelton
authored andcommitted
[DOC-12618]: Feedback on Language Constructs | Couchbase Docs (#292)
Corrected grammar. Added `crc_go_iso` function.
1 parent f73164a commit 0f9c608

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

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

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Replaces any existing value with the specified key.
5252
This operation throws an exception if the underlying bucket SET operation fails with an unexpected error.
5353

5454
|DELETE
55-
|`operator[]` appears afer the JavaScript delete keyword.
55+
|`operator[]` appears after the JavaScript delete keyword.
5656

5757
Deletes the provided key from the KV bucket that the variable is bound to.
5858
Returns a no-op if the object does not exist.
@@ -109,7 +109,7 @@ These operations are accessible through the returned iterable handle.
109109
{sqlpp} Query results, through the SELECT operation, are streamed in batches to the iterable handle as the iteration progresses through the result set.
110110

111111
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.
113113
To work around this, you can use the exposed data service KV map in your Eventing Function.
114114

115115
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.
196196

197197
The following features are not supported by Eventing Functions:
198198

199-
* <<global_state,Global State>>
199+
* <<global-state,Global State>>
200200
* <<asynchrony,Asynchrony>>
201201
* <<browser_extensions,Browser and Other Extensions>>
202202
* <<library_imports,Library Imports>>
@@ -227,7 +227,7 @@ For example, a Constant alias of `debug` with a value of `true` or `false` behav
227227
Eventing Functions do not support asynchronous flows.
228228

229229
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.
231231

232232
You can use Timers to add limited asynchrony back into your Function.
233233
Timers are designed specifically to prevent a state from being node-specific.
@@ -267,6 +267,7 @@ Eventing Functions support the following built-in functions:
267267
* <<n1ql_call,`N1QL()`>>
268268
* <<analytics_call,`ANALYTICS()`>>
269269
* <<crc64_call,`crc64()`>>
270+
* <<crc_64_go_iso_call, `crc_64_go_iso()`>>
270271
* <<base64_call,`base64()`>>
271272
* <<timers_general,`createTimer()` and `cancelTimer()`>>
272273
* <<curl_call,`curl()`>>
@@ -290,7 +291,7 @@ The `N1QL()` function contains the following parameters:
290291
|The identified {sqlpp} statement.
291292
This is passed to {sqlpp} through SDK to run as a prepared statement.
292293

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.
294295

295296
|`params`
296297
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
377378
[#analytics_call]
378379
=== `ANALYTICS()`
379380

381+
ifeval::['{page-component-version}' == '7.6']
382+
383+
[.status]#Introduced in Couchbase Server 7.6#
384+
endif::[]
385+
380386
The `ANALYTICS()` function provides integration with {sqlpp} Analytics directly from the Eventing Service.
381387

382388
Integrating Eventing with Analytics:
@@ -430,7 +436,7 @@ The `crc64()` function takes the object to checksum as its only parameter.
430436
The parameter can be any JavaScript object that can be encoded to JSON.
431437

432438
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.
434440

435441
If multiple Eventing Functions share the same `crc64` checksum documents as the Sync Gateway, real mutations can be suppressed and missed.
436442
To prevent this from happening, you can make the checksum documents unique to each Eventing Function.
@@ -464,10 +470,43 @@ function OnUpdate(doc, meta) {
464470
// Business logic goes in here
465471
}
466472
----
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+
467502

468503
[#base64_call]
469504
=== `base64()`
470505

506+
ifeval::['{page-component-version}' == '7.6']
507+
[.status]#Introduced in Couchbase Server 7.6#
508+
endif::[]
509+
471510
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.
472511
This encoding process stores and transmits arrays as text, ensuring data integrity and compatibility with text-based systems.
473512

@@ -478,7 +517,7 @@ The following `base64()` functions are available:
478517
[source,javascript]
479518
----
480519
function OnUpdate(doc, meta) {
481-
var base_str = base64Encode(doc);
520+
var base_str = couchbase.base64Encode(doc);
482521
/// Code goes here
483522
}
484523
----
@@ -488,20 +527,20 @@ function OnUpdate(doc, meta) {
488527
[source,javascript]
489528
----
490529
function OnUpdate(doc, meta) {
491-
var base_str = base64Decode(doc);
530+
var base_str = couchbase.base64Decode(doc);
492531
/// Code goes here
493532
}
494533
----
495534
+
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.
500539

501540
[#timers_general]
502541
=== `createTimer()` and `cancelTimer()`
503542

504-
Timers are asynchronous compute.
543+
Timers are asynchronously computed.
505544
They allow Eventing Functions to execute in reference to wall-clock events.
506545

507546
[#createtimer_call]

0 commit comments

Comments
 (0)