Liking cljdoc? Tell your friends :D

count

You can use clojure.core/count as an aggregate function! It does pretty much what you expect, count rows within a group.

Has an optional expr argument if you want to count rows only where some predicate holds (handy!).

;; QUERY
[[:from :Order]
 [:agg [:customer-id] 
  [:number-of-orders count]
  [:number-of-refunded-orders [count :refunded]]]]
  
;; STATE
{:Order [{:customer-id 42, :order-id 0}, {:customer-id 42, :order-id 1, :refunded true}]}

;; RESULT
[{:customer-id 42, :number-of-orders 2, :number-of-refunded-orders 1}]

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close