Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions modules/eventing/pages/eventing-language-constructs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Eventing Functions support the following built-in functions:
* <<n1ql_call,`N1QL()`>>
* <<analytics_call,`ANALYTICS()`>>
* <<crc64_call,`crc64()`>>
* <<base64_call,`base64()`>>
* <<timers_general,`createTimer()` and `cancelTimer()`>>
* <<curl_call,`curl()`>>

Expand Down Expand Up @@ -468,6 +469,43 @@ function OnUpdate(doc, meta) {
}
----

[#base64_call]
=== `base64()`

ifeval::['{page-component-version}' == '7.6']
_(Introduced in Couchbase Server 7.6.2)_
endif::[]

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.
This encoding process stores and transmits arrays as text, ensuring data integrity and compatibility with text-based systems.

The following `base64()` functions are available:

* `base64Encode()`, which takes a JSON argument and returns a base64 string.
+
[source,javascript]
----
function OnUpdate(doc, meta) {
var base_str = base64Encode(doc);
/// Code goes here
}
----
+
* `base64Decode()`, which takes a base64 encoded string and returns a value string.
+
[source,javascript]
----
function OnUpdate(doc, meta) {
var base_str = base64Decode(doc);
/// Code goes here
}
----
+
* `base64Float32ArrayEncode()`, which takes a float32 number array and returns a base64 string.
* `base64Float32ArrayDecode()`, which takes a base64 encoded string and returns a float32 number array.
* `base64Float64ArrayEncode()`, which takes a float64 number array and returns a base64 string.
* `base64Float64ArrayDecode()`, which takes a base64 encoded string and returns a float64 number array.

[#timers_general]
=== `createTimer()` and `cancelTimer()`

Expand Down