Count

Not available in this language yet.
Not available in this language yet.
Count( arrayOrSet )
Count( arrayOrSet )
Not available in this language yet.
Not available in this language yet.
Count( arrayOrSet )
Not available in this language yet.

Description

The Count function returns the number of items that exist in arrayOrSet, which is an Array, Page, or Set.

If you use Count on a collection containing many documents, there is a chance that evaluating the count could exceed the transaction time limit of 30 seconds.

Parameters

Argument Type Definition and Requirements

arrayOrSet

Array, Page, or Set

The array, page, or set that should have its items counted.

Returns

The Number of items in arrayOrSet.

Examples

The following query returns the number of items in the provided array:

System.out.println(
    client.query(
        Count(
            Arr(
                Value(1), Value(2), Value(3), Value(4), Value(5),
                Value(6), Value(7), Value(8), Value(9), Value(10)
            )
        )
    ).get()
);
client.query(
  q.Count([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
)
.then((ret) => console.log(ret))
println(Await.result(
  client.query(
    Count(Arr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
  ),
  5.seconds)
)
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
10
10
10

Was this article helpful?

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

Thank you for your feedback!