Skip to content

Instantly share code, notes, and snippets.

@danielbraun
Created April 7, 2019 23:26
Show Gist options
  • Save danielbraun/f3ad8d4f389ef94737b1123e60cc55c1 to your computer and use it in GitHub Desktop.
Save danielbraun/f3ad8d4f389ef94737b1123e60cc55c1 to your computer and use it in GitHub Desktop.
(let [per-page 25
page 2
page-count (sql/call :ceiling (sql/call :/ :%count.* per-page))
]
(-> {:select [[:%count.* :total_count]
[page-count :page-count]
[(sql/call :< page page-count) :has-next?]
[(sql/call :> page 1) :has-previous?]
[page :current_page]
]
:from [:accounts]}
db/query
clojure.pprint/print-table))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment