From 1e6a85816ac4e9c65f8deeecce6a2a804fc8fa4c Mon Sep 17 00:00:00 2001 From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:06:32 +0900 Subject: [PATCH] Add some see also for each of the min and max methods --- .../functions/database/array.mdx | 39 +++++++++++++++---- .../doc-surrealql/functions/database/math.mdx | 14 +++++-- .../doc-surrealql/functions/database/time.mdx | 20 ++++++++-- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/content/doc-surrealql/functions/database/array.mdx b/src/content/doc-surrealql/functions/database/array.mdx index f207ca8db..a59f18797 100644 --- a/src/content/doc-surrealql/functions/database/array.mdx +++ b/src/content/doc-surrealql/functions/database/array.mdx @@ -1278,11 +1278,10 @@ For a similar function that allows using a closure on entire values instead of e ## `array::max` -The `array::max` function returns the maximum item in an array. - +The `array::max` function returns the greatest value from an array of values. ```surql title="API DEFINITION" -array::max(array) -> any +array::max(array) -> any ``` The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement: @@ -1292,7 +1291,19 @@ RETURN array::max([0, 1, 2]); 2 ``` -
+As any value can be compared with another value, the array can be an array of any SurrealQL value. + +```surql +array::max([NONE, NULL, 9, 9.9]); + +9.9f +``` + +See also: + +* [`math::max`](/docs/surrealql/functions/database/math#mathmax), which extracts the greatest number from an array of numbers +* [`time::max`](/docs/surrealql/functions/database/time#timemax), which extracts the greatest datetime from an array of datetimes +* [How values are compared and ordered in SurrealDB](/docs/surrealql/datamodel/values#comparing-and-ordering-values) ## `array::matches` @@ -1321,12 +1332,12 @@ RETURN array::matches([{id: r"ohno:0"}, {id: r"ohno:1"}], {id: r"ohno:1"}); ## `array::min` -The `array::min` function returns the minimum item in an array. - +The `array::min` function returns the least value from an array of values. ```surql title="API DEFINITION" -array::min(array) -> any +array::min(array) -> any ``` + The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement: ```surql @@ -1335,7 +1346,19 @@ RETURN array::min([0, 1, 2]); 0 ``` -
+As any value can be compared with another value, the array can be an array of any SurrealQL value. + +```surql +array::min([NONE, NULL, 9, 9.9]); + +NONE +``` + +See also: + +* [`math::min`](/docs/surrealql/functions/database/math#mathmin), which extracts the least number from an array of numbers +* [`time::min`](/docs/surrealql/functions/database/time#timemin), which extracts the least datetime from an array of datetimes +* [How values are compared and ordered in SurrealDB](/docs/surrealql/datamodel/values#comparing-and-ordering-values) ## `array::pop` diff --git a/src/content/doc-surrealql/functions/database/math.mdx b/src/content/doc-surrealql/functions/database/math.mdx index 71b84aef3..0fc33f90f 100644 --- a/src/content/doc-surrealql/functions/database/math.mdx +++ b/src/content/doc-surrealql/functions/database/math.mdx @@ -929,7 +929,7 @@ RETURN math::log2_e; ## `math::max` -The `math::max` function returns the maximum number in a set of numbers. +The `math::max` function returns the greatest number from an array of numbers. ```surql title="API DEFINITION" math::max(array) -> number @@ -942,7 +942,10 @@ RETURN math::max([ 26.164, 13.746189, 23, 16.4, 41.42 ]); 41.42 ``` -
+See also: + +* [`array::max`](/docs/surrealql/functions/database/array#arraymax), which extracts the greatest value from an array of values +* [`time::max`](/docs/surrealql/functions/database/time#timemax), which extracts the greatest datetime from an array of datetimes ## `math::mean` @@ -997,7 +1000,7 @@ RETURN math::midhinge([ 1, 40, 60, 10, 2, 901 ]); ## `math::min` -The `math::min` function returns the minimum number in a set of numbers. +The `math::min` function returns the least number from an array of numbers. ```surql title="API DEFINITION" math::min(array) -> number @@ -1010,7 +1013,10 @@ RETURN math::min([ 26.164, 13.746189, 23, 16.4, 41.42 ]); 13.746189 ``` -
+See also: + +* [`array::min`](/docs/surrealql/functions/database/array#arraymax), which extracts the least value from an array of values +* [`time::max`](/docs/surrealql/functions/database/time#timemax), which extracts the least datetime from an array of datetimes ## `math::mode` diff --git a/src/content/doc-surrealql/functions/database/time.mdx b/src/content/doc-surrealql/functions/database/time.mdx index efe9d86fd..5459213cf 100644 --- a/src/content/doc-surrealql/functions/database/time.mdx +++ b/src/content/doc-surrealql/functions/database/time.mdx @@ -263,11 +263,12 @@ RETURN time::hour(d"2021-11-01T08:30:17+00:00"); ## `time::max` -The `time::max` function extracts the maximum as a number from a datetime. +The `time::max` function returns the greatest datetime from an array of datetimes. ```surql title="API DEFINITION" -time::max(array) -> datetime +time::max(array) -> datetime ``` + The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement: ```surql @@ -276,6 +277,11 @@ RETURN time::max([ d"1987-06-22T08:30:45Z", d"1988-06-22T08:30:45Z" ]) d"1988-06-22T08:30:45Z" ``` +See also: + +* [`array::max`](/docs/surrealql/functions/database/array#arraymax), which extracts the greatest value from an array of values +* [`math::max`](/docs/surrealql/functions/database/math#mathmax), which extracts the greatest number from an array of numbers +
## `time::micros` @@ -318,11 +324,12 @@ RETURN time::millis(d"1987-06-22T08:30:45Z"); ## `time::min` -The `time::min` function extracts the minimum as a number from a datetime. +The `time::min` function returns the least datetime from an array of datetimes. ```surql title="API DEFINITION" -time::min(array) -> datetime +time::min(array) -> datetime ``` + The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement: ```surql @@ -331,6 +338,11 @@ RETURN time::min([ d"1987-06-22T08:30:45Z", d"1988-06-22T08:30:45Z" ]) d"1987-06-22T08:30:45Z" ``` +See also: + +* [`array::min`](/docs/surrealql/functions/database/array#arraymax), which extracts the least value from an array of values +* [`math::min`](/docs/surrealql/functions/database/math#mathmin), which extracts the least number from an array of numbers +
## `time::minute`