Skip to main content

Count

In this section we'll learn how to count results

By definition:#

  • The form count(predicate) counts how many predicate edges lead out of a node.
  • The form count(uid) counts the number of UIDs matched in the enclosing block.

Counting with dqlx#

To count predicates we use the Count function within the Select statement.
We then pass as the argument the predicate we want to count

db.QueryType("Actor").Select(
"uid",
"name",
dqlx.Count("films")
)

Alias#

Use the Alias function to alias the count attribute

db.QueryType("Actor").Select(
"uid",
"name",
dql.Alias("count", dqlx.Count("films"))
)