Min

Not available in this language yet.
Min( value_1, value_2, ... )
Min( value_1, value_2, ... )
Min( value_1, value_2, ... )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Min( value_1, value_2, ... )

Description

The Min function returns the smallest value in a list of values.

Parameters

Argument Type Definition and Requirements

value

List of values

A single value or a list of values.

Returns

A value which is the minimum value from the value list.

Examples

The query below 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.

System.out.println(
    client.query(
        Arr(
          Min(Value(1), Value(5), Value(22)),
          Min(Value(1), Value(0), Value(3), Value(-1)),
          Min(Value(-1), Value(12), Value(3), Value(-1)),
          Min(Value(10))
        )
    ).get()
);
client.query([
  q.Min(1, 5, 22),
  q.Min(1, 0, 3, -1),
  q.Min(-1, 12, 3, -1),
  q.Min(10),
])
.then((ret) => console.log(ret))
result, err := client.Query(
  f.Arr{
    f.Min(1, 5, 22),
    f.Min(1, 0, 3, -1),
    f.Min(-1, 12, 3, -1),
    f.Min(10)})

  if (err != nil) {
    fmt.Println(err)
  } else {
    fmt.Println(result)
  }
}
println(Await.result(
  client.query(
    Arr(
      Min(1, 5, 22),
      Min(1, 0, 3, -1),
      Min(-1, 12, 3, -1),
      Min(10)
    )
  ),
  5.seconds
))
  client.close()
}
[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:

System.out.println(
    client.query(Arr(
        Min("A", "B", "C", "D"),
        Min(Time("1970-01-01T00:00:00Z"), Time("1980-01-01T00:00:00Z")),
        Min(Date("1970-01-01"), Date("1930-01-01")),
        Min("A", 1)
    )).get());
client.query([
  q.Min('A', 'B', 'C', 'D'),
  q.Min(q.Time('1970-01-01T00:00:00Z'), q.Time('1980-01-01T00:00:00Z')),
  q.Min(q.Date('1970-01-01'), q.Date('1930-01-01')),
  q.Min('A', 1),
])
.then((ret) => console.log(ret))
result, err := client.Query(
  f.Arr{
    f.Min("A", "B", "C", "D"),
    f.Min(f.Time("1970-01-01T00:00:00Z"), f.Time("1980-01-01T00:00:00Z")),
    f.Min(f.Date("1970-01-01"), f.Date("1930-01-01")),
    f.Min("A", 1)})

  if (err != nil) {
    fmt.Println(err)
  } else {
    fmt.Println(result)
  }
}
println(Await.result(
  client.query(
    Arr(
      Min("A", "B", "C", "D"),
      Min(Time("1970-01-01T00:00:00Z"), Time("1980-01-01T00:00:00Z")),
      Min(Date("1970-01-01"), Date("1930-01-01")),
      Min("A", 1)
    )
  ),
  5.seconds
))
  client.close()
}
["A", 1970-01-01T00:00:00Z, 1930-01-01, 1]
[ 'A', Time("1970-01-01T00:00:00Z"), Date("1930-01-01"), 1 ]
[A {0 62135596800 <nil>} {0 60873292800 <nil>} 1]
["A", 1970-01-01T00:00:00Z, 1930-01-01, 1]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!