From 8b9931b32ea941c121b139bd1360ded600fc0044 Mon Sep 17 00:00:00 2001 From: Dave MacLeod <56599343+Dhghomon@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:21:54 +0900 Subject: [PATCH] Add some see also for each of the min and max methods (#1085) --- .../functions/database/array.mdx | 43 ++++++++++++++----- .../doc-surrealql/functions/database/math.mdx | 18 +++++--- .../doc-surrealql/functions/database/time.mdx | 24 ++++++++--- 3 files changed, 63 insertions(+), 22 deletions(-) diff --git a/src/content/doc-surrealql/functions/database/array.mdx b/src/content/doc-surrealql/functions/database/array.mdx index f207ca8db..31a13ec30 100644 --- a/src/content/doc-surrealql/functions/database/array.mdx +++ b/src/content/doc-surrealql/functions/database/array.mdx @@ -156,7 +156,7 @@ These functions can be used when working with, and manipulating arrays of data. array::max() - Returns the maximum item in an array + Returns the greatest item from an array array::matches() @@ -164,7 +164,7 @@ These functions can be used when working with, and manipulating arrays of data. array::min() - Returns the minimum item in an array + Returns the least item from an array array::pop() @@ -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..256ab44a8 100644 --- a/src/content/doc-surrealql/functions/database/math.mdx +++ b/src/content/doc-surrealql/functions/database/math.mdx @@ -168,7 +168,7 @@ These functions can be used when analysing numeric data and numeric collections. math::max() - Returns the maximum number in a set of numbers + Returns the greatest number from an array of numbers math::mean() @@ -184,7 +184,7 @@ These functions can be used when analysing numeric data and numeric collections. math::min() - Returns the minimum number in a set of numbers + Returns the least number from an array of numbers math::mode() @@ -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#arraymin), which extracts the least value from an array of values +* [`time::min`](/docs/surrealql/functions/database/time#timemin), 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..1a4887670 100644 --- a/src/content/doc-surrealql/functions/database/time.mdx +++ b/src/content/doc-surrealql/functions/database/time.mdx @@ -57,7 +57,7 @@ time::yday(); time::max() - Finds the most recent datetime in an array + Returns the greatest datetime from an array time::micros() @@ -69,7 +69,7 @@ time::yday(); time::min() - Finds the least recent datetime in an array + Returns the least datetime from an array time::minute() @@ -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#arraymin), 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`