Min
Min( value_1, value_2, ... )
Min( value_1, value_2, ... )
Min( value_1, value_2, ... )
Min( value_1, value_2, ... )
min( value_1, value_2, ... )
Min( value_1, value_2, ... )
Description
The Min
function returns the smallest value in a list of
values.
Types have an order of precedence. When comparing values of different types, they are ranked in the following order, from least to greatest.
With this precedence, Numbers are always smaller than Strings.
The run time of For query "width" errors, the underlying set or page involves more than
100K items. This can happen when using a set function, such as
For example, instead of:
use:
This does mean that if the entire set must be evaluated to arrive at the
correct result, you would have to page through the For query timeout errors, you may specify a larger query timeout via the driver that you are using. |
Examples
The following query executes an array of independent min operations and returns the results in an array. The result array position matches the execution array position. The top operation in the execution array, minimum of the values 1, 5, and 22, returns a long value of 1 in the top position of the result array.
Arr(LongV(1), LongV(-1), LongV(-1), LongV(10))
[1 -1 -1 10]
[1, -1, -1, 10]
[ 1, -1, -1, 10 ]
[1, -1, -1, 10]
[ 1, -1, -1, 10 ]
The following query uses the same approach as the previous query to
demonstrate using Min
with various types of values:
Arr(StringV(A), LongV(10), FaunaTime(1970-01-01T00:00:00Z), FaunaDate(1930-01-01 12:00:00 AM), LongV(1), BooleanV(False), ObjectV(x: LongV(10)), Arr(StringV(A)), Arr(StringV(A), StringV(B)))
[A 10 {0 62135596800 <nil>} {0 60873292800 <nil>} 1 false map[x:10] [A] [A B]]
["A", 10, 1970-01-01T00:00:00Z, 1930-01-01, 1, false, {x: 10}, ["A"], ["A", "B"]]
[
'A',
10,
Time("1970-01-01T00:00:00Z"),
Date("1930-01-01"),
1,
false,
{ x: 10 },
[ 'A' ],
[ 'A', 'B' ]
]
['A', 10, FaunaTime('1970-01-01T00:00:00Z'), datetime.date(1930, 1, 1), 1, False, {'x': 10}, ['A'], ['A', 'B']]
[
'A',
10,
Time("1970-01-01T00:00:00Z"),
Date("1930-01-01"),
1,
false,
{ x: 10 },
[ 'A' ],
[ 'A', 'B' ]
]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!