Skip to content

Commit

Permalink
Add some see also for each of the min and max methods (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhghomon authored Dec 30, 2024
1 parent e71bdaf commit 8b9931b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 deletions.
43 changes: 33 additions & 10 deletions src/content/doc-surrealql/functions/database/array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ These functions can be used when working with, and manipulating arrays of data.
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#arraymax"><code>array::max()</code></a></td>
<td scope="row" data-label="Description">Returns the maximum item in an array</td>
<td scope="row" data-label="Description">Returns the greatest item from an array</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#arraymatches"><code>array::matches()</code></a></td>
<td scope="row" data-label="Description">Returns an array of booleans indicating which elements of the input array contain a specified value.</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#arraymin"><code>array::min()</code></a></td>
<td scope="row" data-label="Description">Returns the minimum item in an array</td>
<td scope="row" data-label="Description">Returns the least item from an array</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#arraypop"><code>array::pop()</code></a></td>
Expand Down 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
18 changes: 12 additions & 6 deletions src/content/doc-surrealql/functions/database/math.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ These functions can be used when analysing numeric data and numeric collections.
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#mathmax"><code>math::max()</code></a></td>
<td scope="row" data-label="Description">Returns the maximum number in a set of numbers</td>
<td scope="row" data-label="Description">Returns the greatest number from an array of numbers</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#mathmean"><code>math::mean()</code></a></td>
Expand All @@ -184,7 +184,7 @@ These functions can be used when analysing numeric data and numeric collections.
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#mathmin"><code>math::min()</code></a></td>
<td scope="row" data-label="Description">Returns the minimum number in a set of numbers</td>
<td scope="row" data-label="Description">Returns the least number from an array of numbers</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#mathmode"><code>math::mode()</code></a></td>
Expand Down 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#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`

Expand Down
24 changes: 18 additions & 6 deletions src/content/doc-surrealql/functions/database/time.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ time::yday();
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timemax"><code>time::max()</code></a></td>
<td scope="row" data-label="Description">Finds the most recent datetime in an array</td>
<td scope="row" data-label="Description">Returns the greatest datetime from an array</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timemicros"><code>time::micros()</code></a></td>
Expand All @@ -69,7 +69,7 @@ time::yday();
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timemin"><code>time::min()</code></a></td>
<td scope="row" data-label="Description">Finds the least recent datetime in an array</td>
<td scope="row" data-label="Description">Returns the least datetime from an array</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timeminute"><code>time::minute()</code></a></td>
Expand Down 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#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

<br />

## `time::minute`
Expand Down

0 comments on commit 8b9931b

Please sign in to comment.