FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Min
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
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.
-
Number (integers and decimals: 0.5 < 1 < 1.5 < 2)
-
Byte
-
String
-
Array (ordered lexically, like strings)
-
Object (ordered lexically, like strings)
-
Reference
-
Timestamp
-
Date
-
Boolean (false < true)
-
Null
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. |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
List of Values |
A single Value or a list of Values. |
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.
[ 1, -1, -1, 10 ]
[1, -1, -1, 10]
[1 -1 -1 10]
Arr(LongV(1), LongV(-1), LongV(-1), LongV(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:
[
'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 {0 62135596800 <nil>} {0 60873292800 <nil>} 1 false map[x:10] [A] [A B]]
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,
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!