Skip to content

Commit

Permalink
Add some see also for each of the min and max methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhghomon committed Dec 23, 2024
1 parent 4e16f81 commit 1e6a858
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
39 changes: 31 additions & 8 deletions src/content/doc-surrealql/functions/database/array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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>) -> any
```
The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

Expand All @@ -1292,7 +1291,19 @@ RETURN array::max([0, 1, 2]);
2
```

<br />
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`

Expand Down Expand Up @@ -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>) -> any
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

```surql
Expand All @@ -1335,7 +1346,19 @@ RETURN array::min([0, 1, 2]);
0
```

<br />
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`

Expand Down
14 changes: 10 additions & 4 deletions src/content/doc-surrealql/functions/database/math.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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>) -> number
Expand All @@ -942,7 +942,10 @@ RETURN math::max([ 26.164, 13.746189, 23, 16.4, 41.42 ]);
41.42
```

<br />
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`

Expand Down Expand Up @@ -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>) -> number
Expand All @@ -1010,7 +1013,10 @@ RETURN math::min([ 26.164, 13.746189, 23, 16.4, 41.42 ]);
13.746189
```

<br />
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`

Expand Down
20 changes: 16 additions & 4 deletions src/content/doc-surrealql/functions/database/time.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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>) -> datetime
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

```surql
Expand All @@ -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

<br />

## `time::micros`
Expand Down Expand Up @@ -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>) -> datetime
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

```surql
Expand All @@ -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

<br />

## `time::minute`
Expand Down

0 comments on commit 1e6a858

Please sign in to comment.