Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
utilities for going between vector and map form of datomic query
(def query '[:find ?e ?fname ?lname
:in $ ?fname ?lname
:where [?e :user/firstname ?fname]
[?e :user/lastName ?lname]])
(defn group-by-kw [v]
(map (fn [[[f] l]] (conj [f] l))
(partition 2 (partition-by keyword? v))))
(defn query-vec-as-map [vquery]
(into {} (group-by-kw vquery)))
(defn query-map-as-vec [mquery]
(vec (apply concat
(map (fn [[f fr]] (cons f fr))
(into [] mquery)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment