LIMIT keeps the first N rows of data in the data stream, and discard the rest rows.
Syntax: LIMIT <number>
Input:
- <number>: The number of rows to be kept, or to keep all rows when set to -1
find().nodes([1, 5]) as nodes
n(nodes).e()[:2].n() as path
limit 2
return path
In the UQL above, LIMIT keeps the first 2 rows of path resulted from the template query:
See UQL and image below to compare Clause LIMIT and Chain Command Parameter .limit()
find().nodes([1, 5]) as nodes
n(nodes).e()[:2].n().limit(2) as path
return path
Parameter .limit()
keeps the first 2 rows of path resulted from each subquery of the template query:
Common Usage
Example: find all cards that transferred money to Card CA029, return 10 cards in a descending order of their balances; that is, to find the 10 cards with the highest balances
n({_id == "CA029"}).le({@transfer}).n({@card} as n)
with distinct (n)
order by n.balance DESC
return n{*} limit 10
Example: find all cards that transferred money to Card CA029, return them in a descending order of their balances
n({_id == "CA029"}).le({@transfer}).n({@card} as n)
with distinct (n)
limit 10 return n{*}
order by n.balance DESC