Carrot reference
Methods

.count()

Returns the number of items in a Sequence or List.

Syntax

.count()

  • Returns the total number of items in the Sequence or List

.count{expression}

  • Returns the number of items in the Sequence or List where the expression evaluates to a truthy value

Examples

  • [1, 2, 3].count() returns 3
  • [1, 2, 3].count{it >= 2} returns 2
  • db.job.find{dept:engineering}.count() returns the number of jobs in the Engineering department.
  • db.job.find{dept:engineering}.count{baseComp > 100000} returns the number of jobs in the Engineering department where base compensation is at least $100k.