Product SiteDocumentation Site

10.7. Count Clauses

For each incoming tuple, a binding from the position of this tuple in the tuple stream to the count variable is added. The new tuple is then forwarded to the next clause.
Example 10.20. A count clause.
for $question in collection("faqs")
order by size($question.tags)
count $count
return {
  "id" : $count,
  "faq" : $question.title
}
Results:
{
  "id" : 1,
  "faq" : "MySQL and NoSQL: Help me to choose the right one
"
}
{
  "id" : 2,
  "faq" : "The Next-gen Databases"
}
{
  "id" : 3,
  "faq" : "Redis, CouchDB or Cassandra?"
}
{
  "id" : 4,
  "faq" : "Find CouchDB docs missing an arbitrary field"
}
{
  "id" : 5,
  "faq" : "Full-text search in NoSQL databases"
}