Function count()
calculates the number of rows of an alias. Only one row from the alias will be kept after this function is called, and all the rest rows will be abandoned.
Arguments:
- Any Value <any>
Returns:
- Number of Rows <number>
ATTR
Example: deduplicate the elements in an array, count the number of the elements after deduplication
uncollect [1,2,4,5,2,1,3] as a
with distinct(a) as b
return count(b)
Node
Example: find @device
nodes, count the number of them
find().nodes({@device}) as n
return count(n)
Edge
Example: find @view
edges, count the number of it
find().edges({@view}) as e
return count(e)
Path
Example: find the shortest paths from Card CA001 to CA002 within 5 steps, count the number of the paths
n({_id == "CA001"}).e()[*:5].n({_id == "CA002"}) as p
return count(p)