From 378009f44abc751d93301bddab1202101b2d3792 Mon Sep 17 00:00:00 2001
From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com>
Date: Fri, 30 Aug 2024 13:49:26 +0900
Subject: [PATCH] Add missing functions (#798)
---
.../surrealql/functions/database/array.mdx | 208 ++++++++++++++++++
.../surrealql/functions/database/bytes.mdx | 48 ++++
.../surrealql/functions/database/count.mdx | 2 +-
.../surrealql/functions/database/crypto.mdx | 27 ++-
.../surrealql/functions/database/duration.mdx | 2 +-
.../surrealql/functions/database/encoding.mdx | 2 +-
.../surrealql/functions/database/geo.mdx | 2 +-
.../surrealql/functions/database/http.mdx | 2 +-
.../surrealql/functions/database/index.mdx | 4 +
.../surrealql/functions/database/math.mdx | 24 +-
.../surrealql/functions/database/meta.mdx | 2 +-
.../surrealql/functions/database/object.mdx | 2 +-
.../surrealql/functions/database/parse.mdx | 26 ++-
.../surrealql/functions/database/rand.mdx | 4 +-
.../surrealql/functions/database/record.mdx | 2 +-
.../surrealql/functions/database/search.mdx | 2 +-
.../surrealql/functions/database/session.mdx | 54 ++++-
.../surrealql/functions/database/sleep.mdx | 2 +-
.../surrealql/functions/database/string.mdx | 27 ++-
.../surrealql/functions/database/time.mdx | 31 ++-
.../surrealql/functions/database/type.mdx | 2 +-
.../surrealql/functions/database/value.mdx | 2 +-
.../surrealql/functions/database/vector.mdx | 32 ++-
23 files changed, 475 insertions(+), 34 deletions(-)
create mode 100644 doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/bytes.mdx
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/array.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/array.mdx
index dadf82311..991c07a7c 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/array.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/array.mdx
@@ -78,6 +78,10 @@ These functions can be used when working with, and manipulating arrays of data.
array::distinct() |
Returns the unique items in an array |
+
+ array::fill() |
+ Fills an existing array of the same value |
+
array::filter() |
Filters out values that do not match a pattern |
@@ -114,6 +118,10 @@ These functions can be used when working with, and manipulating arrays of data.
array::intersect() |
Returns the values which intersect two arrays |
+
+ array::is_empty() |
+ Checks if an array is empty |
+
array::join() |
Returns concatenated value of an array with a string in between. |
@@ -166,14 +174,26 @@ These functions can be used when working with, and manipulating arrays of data.
array::push() |
Appends an item to the end of an array |
+
+ array::range() |
+ Creates a number array from a range (start to end) |
+
array::remove() |
Removes an item at a specific position from an array, supports negative index |
+
+ array::repeat() |
+ Creates an array of the same value of a given size |
+
array::reverse() |
Reverses the sorting order of an array |
+
+ array::shuffle() |
+ Randomly shuffles the contents of an array |
+
array::sort() |
Sorts the values in an array in ascending or descending order |
@@ -190,6 +210,10 @@ These functions can be used when working with, and manipulating arrays of data.
array::sort::desc() |
Sorts the values in an array in descending order |
+
+ array::swap() |
+ Swaps two items in an array |
+
array::transpose() |
Performs 2d array transposition on two arrays |
@@ -547,6 +571,48 @@ RETURN array::distinct([ 1, 2, 1, 3, 3, 4 ]);
+## `array::fill`
+
+
+
+The `array::fill` function replaces all values of an array with a new value.
+
+```surql title="API DEFINITION"
+array::fill(array, any) -> array
+```
+
+The function also accepts a third and a fourth parameter which allows you to replace only a portion of the source array.
+
+```surql title="API DEFINITION"
+array::fill(array, any, start: int, end: int) -> array
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN array::fill([ 1, 2, 3, 4, 5 ], 10);
+
+[ 10, 10, 10, 10, 10 ]
+```
+
+The following example shows how you can use this function with a starting position, and an ending position, which in this example will replace one item from the array:
+
+```surql
+RETURN array::fill([ 1, NONE, 3, 4, 5 ], 10, 1, 2);
+
+[ 1, 10, 3, 4, 5 ]
+```
+
+The following example shows how you can use this function with starting and ending negative positions, which in this example will replace one item from the array:
+
+```surql
+RETURN array::fill([ 1, 2, NONE, 4, 5 ], 10, -3, -2);
+
+[ 1, 2, 10, 4, 5 ]
+```
+
+
+
## `array::filter`
The `array::filter` function filters out values in an array that do not match a pattern, returning only the ones that do match.
@@ -795,6 +861,31 @@ RETURN array::intersect([1,2,3,4], [3,4,5,6]);
+## `array::is_empty`
+
+
+
+The `array::is_empty` checks whether the array contains values.
+
+```surql title="API DEFINITION"
+array::is_empty(array) -> bool
+```
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql title="An array that contain values"
+RETURN array::is_empty([1,2,3,4]);
+
+false
+```
+
+```surql title="An empty array"
+RETURN array::is_empty([]);
+
+true
+```
+
+
+
## `array::join`
The `array::join` function takes an array and a string as parameters and returns a concatenated string.
@@ -1126,6 +1217,31 @@ RETURN array::push([1,2,3,4], 5);
+## `array::range`
+
+
+
+The `array::range` function creates an array of numbers from a given range.
+
+```surql title="API DEFINITION"
+array::range(start, end) -> array
+```
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN array::range(1, 10);
+
+[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
+```
+
+```surql
+RETURN array::range(3, 2);
+
+[ 3, 4 ]
+```
+
+
+
## `array::remove`
The `array::remove` function removes an item from a specific position in an array, supports negative index.
@@ -1151,6 +1267,31 @@ RETURN array::remove([1,2,3,4,5], -2);
+## `array::repeat`
+
+
+
+The `array::repeat` function creates an array of a given size that will contain the same value.
+
+```surql title="API DEFINITION"
+array::repeat(any, count) -> array
+```
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN array::repeat(1, 10);
+
+[ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 ]
+```
+
+```surql
+RETURN array::repeat("hello", 2);
+
+[ "hello", "hello" ]
+```
+
+
+
## `array::reverse`
The `array::reverse` function reverses the sorting order of an array.
@@ -1169,6 +1310,26 @@ RETURN array::reverse([ 1, 2, 3, 4, 5 ]);
+## `array::shuffle`
+
+
+
+The `array::shuffle` function randomly shuffles the items of an array.
+
+```surql title="API DEFINITION"
+array::shuffle(array) -> array
+```
+
+The following example shows this function, and its possible output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN array::shuffle([ 1, 2, 3, 4, 5 ]);
+
+[ 2, 1, 4, 3, 5 ]
+```
+
+
+
## `array::sort`
The `array::sort` function sorts the values in an array in ascending or descending order.
@@ -1298,6 +1459,53 @@ RETURN array::sort::desc([ 1, 2, 1, null, "something", 3, 3, 4, 0 ]);
+## `array::swap`
+
+
+
+The `array::swap` swaps two values of an array based on indexes.
+
+
+```surql title="API DEFINITION"
+array::swap(array, from: int, to: int) -> array
+```
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN array::swap(["What's", "its", "got", "in", "it", "pocketses?"], 1, 4);
+```
+
+```bash title="Output"
+[
+ "What's",
+ 'it',
+ 'got',
+ 'in',
+ 'its',
+ 'pocketses?'
+]
+```
+
+The following example shows how you can use this function with a positive index, and a negative index, which will swap the first and last element from the array:
+
+```surql
+RETURN array::swap([ 1, 2, 3, 4, 5 ], 0, -1);
+
+[ 5, 2, 3, 4, 1 ]
+```
+
+An error will be returned if any of the indexes are invalid that informs of range of possible indexes that can be used.
+
+```surql
+RETURN array::swap([0,1], 100, 1000000);
+```
+
+```bash title="Output"
+'Incorrect arguments for function array::swap(). Argument 1 is out of range. Expected a number between -2 and 2'
+```
+
+
+
## `array::transpose`
The `array::transpose` is used to perform 2d array transposition but its behavior in cases of arrays of differing sizes can be best described as taking in multiple arrays and 'layering' them on top of each other.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/bytes.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/bytes.mdx
new file mode 100644
index 000000000..f87ece232
--- /dev/null
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/bytes.mdx
@@ -0,0 +1,48 @@
+---
+sidebar_position: 3
+sidebar_label: Bytes functions
+title: Bytes functions | SurrealQL
+description: These functions can be used when working with bytes.
+---
+
+# Bytes functions
+
+These functions can be used when working with bytes in SurrealQL.
+
+
+
+
+ Function |
+ Description |
+
+
+
+
+ bytes::len() |
+ Gives the length in bytes |
+
+
+
+
+## `bytes::len`
+
+The `bytes::len` function returns the length in bytes of a `bytes` value.
+
+
+```surql title="API DEFINITION"
+bytes::len(bytes) -> int
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN [
+ bytes::len("Simple ASCII string"),
+ bytes::len("οὐ γὰρ δυνατόν ἐστιν ἔτι καθεύδειν"),
+ bytes::len("청춘예찬 靑春禮讚")
+];
+```
+
+```bash title="Output"
+[ 19, 67, 25 ]
+```
\ No newline at end of file
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/count.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/count.mdx
index 03f1b93c3..52eabb711 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/count.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/count.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 3
+sidebar_position: 4
sidebar_label: Count function
title: Count function | SurrealQL
description: These functions can be used when counting field values and expressions.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/crypto.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/crypto.mdx
index 1fda77b2b..9ad5d6f5a 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/crypto.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/crypto.mdx
@@ -1,10 +1,12 @@
---
-sidebar_position: 4
+sidebar_position: 5
sidebar_label: Crypto functions
title: Crypto functions | SurrealQL
description: These functions can be used when hashing data, encrypting data, and for securely authenticating users into the database.
---
+import Since from '@site/src/components/Since'
+
# Crypto functions
These functions can be used when hashing data, encrypting data, and for securely authenticating users into the database.
@@ -17,6 +19,10 @@ These functions can be used when hashing data, encrypting data, and for securely
+
+ crypto::md5() |
+ Returns the blake3 hash of a value |
+
crypto::md5() |
Returns the md5 hash of a value |
@@ -68,6 +74,25 @@ These functions can be used when hashing data, encrypting data, and for securely
+## `crypto::blake3`
+
+
+
+The `crypto::blake3` function returns the blake3 hash of the input value.
+
+```surql title="API DEFINITION"
+crypto::blake3(string) -> string
+```
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN crypto::blake3("tobie");
+
+'85052e9aab1b67b6622d94a08441b09fd5b7aca61ee360416d70de5da67d86ca'
+```
+
+
+
## `crypto::md5`
The `crypto::md5` function returns the md5 hash of the input value.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/duration.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/duration.mdx
index 6e4404766..7b183aa76 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/duration.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/duration.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 5
+sidebar_position: 6
sidebar_label: Duration functions
title: Duration functions | SurrealQL
description: These functions can be used when converting between numeric and duration data.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/encoding.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/encoding.mdx
index 8e20ef6c2..340f17f79 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/encoding.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/encoding.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 5
+sidebar_position: 7
sidebar_label: Encoding functions
title: Encoding functions | SurrealQL
description: These functions can be used to encode and decode data in base64. It is particularly used when that data needs to be stored and transferred over media that are designed to deal with text. This encoding and decoding helps to ensure that the data remains intact without modification during transport.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/geo.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/geo.mdx
index 5bc0beaee..74bd0c8e9 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/geo.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/geo.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 6
+sidebar_position: 8
sidebar_label: Geo functions
title: Geo functions | SurrealQL
description: These functions can be used when working with and analysing geospatial data.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/http.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/http.mdx
index f396d8237..c21fd07b4 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/http.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/http.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 7
+sidebar_position: 9
sidebar_label: HTTP functions
title: HTTP functions | SurrealQL
description: These functions can be used when opening and submitting remote web requests, and webhooks.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/index.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/index.mdx
index 4d47e55ea..6fcdcfc08 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/index.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/index.mdx
@@ -23,6 +23,10 @@ SurrealDB comes with a large number of in-built functions for checking, manipula
Array Functions |
array::len([1,2,3]) |
+
+ Bytes functions |
+ bytes::len("SurrealDB".to_bytes()); |
+
Count function |
count([1,2,3]) |
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/math.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/math.mdx
index faa58c73f..046e83cc0 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/math.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/math.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 8
+sidebar_position: 10
sidebar_label: Math functions
title: Math functions | SurrealQL
description: These functions can be used when analysing numeric data and numeric collections.
@@ -146,6 +146,10 @@ These functions can be used when analysing numeric data and numeric collections.
math::pi |
Represents the mathematical constant π. |
+
+ math::pi |
+ Returns a number raised to a power |
+
math::product() |
Returns the product of a set of numbers |
@@ -769,6 +773,24 @@ RETURN math::pi;
+## `math::pow`
+
+The `math::pow` function returns a number raised to the power of a second number.
+
+```surql title="API DEFINITION"
+math::pow(number, number) -> number
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN math::pow(1.07, 10);
+
+1.9671513572895665f
+```
+
+
+
## `math::product`
The `math::product` function returns the product of a set of numbers.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/meta.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/meta.mdx
index dcf44dd4a..2e80a4263 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/meta.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/meta.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 9
+sidebar_position: 11
sidebar_label: Meta functions
title: Meta functions | SurrealQL
description: These functions can be used to retrieve specific metadata from a SurrealDB Record ID.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/object.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/object.mdx
index 2fb5fd921..04733a2a9 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/object.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/object.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 11
+sidebar_position: 12
sidebar_label: Object functions
title: Object functions | SurrealQL
description: These functions can be used when working with, and manipulating data objects.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/parse.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/parse.mdx
index 5797a1552..e7f202dfe 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/parse.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/parse.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 12
+sidebar_position: 13
sidebar_label: Parse functions
title: Parse functions | SurrealQL
description: These functions can be used when parsing email addresses and URL web addresses.
@@ -45,6 +45,10 @@ These functions can be used when parsing email addresses and URL web addresses.
parse::url::port() |
Parses and returns the port number from a URL |
+
+ parse::url::port() |
+ Parses and returns the scheme from a URL |
+
parse::url::query() |
Parses and returns the query string from a URL |
@@ -167,7 +171,7 @@ RETURN parse::url::path("https://surrealdb.com:80/features?some=option#fragment"
## `parse::url::port`
-The `parse::url::port` function parses and returns the port from a valid URL..
+The `parse::url::port` function parses and returns the port from a valid URL.
```surql title="API DEFINITION"
parse::url::port(string) -> bool
@@ -182,6 +186,24 @@ RETURN parse::url::port("https://surrealdb.com:80/features?some=option#fragment"
+## `parse::url::scheme`
+
+The `parse::url::scheme` function parses and returns the scheme from a valid URL, in lowercase, as an ASCII string without the ':' delimiter.
+
+```surql title="API DEFINITION"
+parse::url::scheme(string) -> bool
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN parse::url::scheme("https://surrealdb.com:80/features?some=option#fragment");
+
+'https'
+```
+
+
+
## `parse::url::query`
The `parse::url::query` function parses and returns the query from a valid URL.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/rand.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/rand.mdx
index 13422c12e..742d3b696 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/rand.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/rand.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 13
+sidebar_position: 14
sidebar_label: Rand functions
title: Rand functions | SurrealQL
description: These functions can be used when generating random data values.
@@ -243,8 +243,6 @@ RETURN rand::int(10, 15);
The `rand::string` function generates a random string, with 32 characters.
-
-
```surql title="API DEFINITION"
rand::string() -> string
```
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/record.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/record.mdx
index f2492bf89..993a4650c 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/record.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/record.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 14
+sidebar_position: 15
sidebar_label: Record functions
title: Record functions | SurrealQL
description: These functions can be used to retrieve specific metadata from a SurrealDB Record ID.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/search.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/search.mdx
index fa55c0a51..f327744c9 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/search.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/search.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 15
+sidebar_position: 16
sidebar_label: Search functions
title: Search functions | SurrealQL
description: These functions are used in conjunction with the 'matches' operator to either collect the relevance score or highlight the searched keywords within the content.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/session.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/session.mdx
index edbfcc0f6..4c4f92e9a 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/session.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/session.mdx
@@ -1,9 +1,10 @@
---
-sidebar_position: 16
+sidebar_position: 17
sidebar_label: Session functions
title: Session functions | SurrealQL
description: These functions can be used when working with and manipulating text and string values.
---
+import Since from '@site/src/components/Since'
# Session functions
@@ -17,6 +18,10 @@ These functions can be used when working with and manipulating text and string v
+
+ session::ac() |
+ Returns the current user's access method |
+
session::db() |
Returns the currently selected database |
@@ -38,12 +43,36 @@ These functions can be used when working with and manipulating text and string v
Returns the current user's HTTP origin |
- session::ac() |
- Returns the current user's access method |
+ session::rd() |
+ Returns the current user's record authentication data |
+
+
+ session::token() |
+ Returns the current user's authentication token |
+## `session::ac`
+
+
+
+The `session::ac` function replaces the `session::sc` function and returns the current user's access method.
+
+```surql title="API DEFINITION"
+session::ac() -> string
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN session::ac();
+
+"user"
+```
+
+
+
## `session::db`
The `session::db` function returns the currently selected database.
@@ -129,19 +158,22 @@ RETURN session::origin();
-## `session::ac`
+## `session::rd`
-The `session::ac` function replaces the `session::sc` function and returns the current user's access method.
+
+
+The `session::rd` function returns the current user's record authentication.
```surql title="API DEFINITION"
-session::ac() -> string
+session::rd() -> string
```
-The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
-```surql
-RETURN session::ac();
+## `session::token`
-"user"
+The `session::token` function returns the current authentication token.
+
+```surql title="API DEFINITION"
+session::token() -> string
```
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/sleep.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/sleep.mdx
index 008f777ce..bcdf658ef 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/sleep.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/sleep.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 17
+sidebar_position: 18
sidebar_label: Sleep function
title: Sleep function | SurrealQL
description: These functions can be used to introduce a delay or pause in the execution of a query or a batch of queries for a specific amount of time.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/string.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/string.mdx
index ec97965b5..48f4d8a7f 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/string.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/string.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 18
+sidebar_position: 19
sidebar_label: String functions
title: String functions | SurrealQL
description: These functions can be used when working with and manipulating text and string values.
@@ -43,6 +43,10 @@ These functions can be used when working with and manipulating text and string v
string::lowercase() |
Converts a string to lowercase |
+
+ string::matches() |
+ Performs a regex match on a string |
+
string::repeat() |
Repeats a string a number of times |
@@ -314,6 +318,27 @@ RETURN string::lowercase('THIS IS A TEST');
+## `string::matches`
+
+The `string::matches` function performs a regex match on a string.
+
+```surql title="API DEFINITION"
+string::matches(string, string) -> bool
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN [
+ string::matches("grey", "gr(a|e)y"),
+ string::matches("gray", "gr(a|e)y")
+];
+
+[ true, true ]
+```
+
+
+
## `string::repeat`
The `string::repeat` function repeats a string a number of times.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/time.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/time.mdx
index aacc50a82..270def2f4 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/time.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/time.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 19
+sidebar_position: 20
sidebar_label: Time functions
title: Time functions | SurrealQL
description: These functions can be used when working with and manipulating datetime values.
@@ -18,6 +18,10 @@ These functions can be used when working with and manipulating datetime values.
+
+ time::ceil() |
+ Rounds a datetime up to the next largest duration |
+
time::day() |
Extracts the day as a number from a datetime |
@@ -125,6 +129,31 @@ These functions can be used when working with and manipulating datetime values.
+## `time::ceil`
+
+The `time::ceil` function rounds a datetime up to the next largest duration.
+
+```surql title="API DEFINITION"
+time::ceil(datetime, duration) -> datetime
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+LET $now = d'2024-08-30T02:22:50.231631Z';
+
+RETURN [
+ time::ceil($now, 1h),
+ time::ceil($now, 1w)
+];
+```
+
+```bash title="Output"
+[
+ d'2024-08-30T03:00:00Z',
+ d'2024-09-05T00:00:00Z'
+]
+```
## `time::day`
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/type.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/type.mdx
index 9cc9b08e7..5a433534a 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/type.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/type.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 20
+sidebar_position: 21
sidebar_label: Type functions
title: Type functions | SurrealQL
description: These functions can be used for generating and coercing data to specific data types.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/value.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/value.mdx
index b767f34f4..f6250e54d 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/value.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/value.mdx
@@ -1,5 +1,5 @@
---
-sidebar_position: 21
+sidebar_position: 22
sidebar_label: Value functions
title: Value functions | SurrealQL
description: Functions that can be called on more than one type of SurrealQL value.
diff --git a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/vector.mdx b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/vector.mdx
index 69433a76b..aa64522e2 100644
--- a/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/vector.mdx
+++ b/doc-surrealdb_versioned_docs/version-latest/surrealql/functions/database/vector.mdx
@@ -1,9 +1,10 @@
---
-sidebar_position: 22
+sidebar_position: 23
sidebar_label: Vector functions
title: Vector functions | SurrealQL
description: A collection of essential vector operations that provide foundational functionality for numerical computation, machine learning, and data analysis.
---
+import Since from '@site/src/components/Since'
# Vector functions
@@ -53,6 +54,10 @@ A collection of essential vector operations that provide foundational functional
vector::project() |
Computes the projection of one vector onto another |
+
+ vector::scale |
+ Multiplies each item in a vector |
+
vector::subtract() |
Performs element-wise subtraction between two vectors |
@@ -82,7 +87,7 @@ A collection of essential vector operations that provide foundational functional
Computes the Minkowski distance between two vectors |
- vector::similarity::cosine() |
+ vector::similarity::cosine() |
Computes the Cosine similarity between two vectors |
@@ -256,6 +261,27 @@ RETURN vector::project([1, 2, 3], [4, 5, 6]);
+## `vector::scale`
+
+
+
+The `vector::scale` function multiplies each item in a vector by a number.
+
+
+```surql title="API DEFINITION"
+vector::scale(array, number) -> array
+```
+
+The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealdb/surrealql/statements/return) statement:
+
+```surql
+RETURN vector::scale([3, 1, 5, -3, 7, 2], 5);
+
+[ 15, 5, 25, -15, 35, 10 ]
+```
+
+
+
## `vector::subtract`
The `vector::subtract` function performs element-wise subtraction between two vectors, where each element in the second vector is subtracted from the corresponding element in the first vector.
@@ -450,4 +476,6 @@ RETURN vector::similarity::pearson([1,2,3], [1,5,7]);
0.9819805060619659f
```
+
+