Skip to content

Instantly share code, notes, and snippets.

@ChristopherBiscardi
Created December 7, 2012 05:26
Show Gist options
  • Save ChristopherBiscardi/4231005 to your computer and use it in GitHub Desktop.
Save ChristopherBiscardi/4231005 to your computer and use it in GitHub Desktop.
(:require [monger.collection :as mc]
[monger.conversion :as convert])
;; get distinct values from the posts collection for the field category.
(mc/distinct "posts" "category")
;; get distinct values from the posts collection for the field category with a query.
(mc/distinct "posts" "category" {:limit 5})
;; convert values to maps using an anonymous function
(map
(fn [cat] (convert/from-db-object cat false))
(mc/distinct "posts" "category"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment