 (defn dollar
   [s]
   (str "$" (name s)))
+
+(defn dedup
+  []
+  [{:$group {:_id "$gid" :dedup {:$first "$$ROOT"}}}
+   {:$replaceRoot {:newRoot "$dedup"}}])
+
+(defn dedup-on
+  [field]
+  (let [path (dollar field)]
+    [{:$group {:_id path :dedup {:$first "$$ROOT"}}}
+     {:$replaceRoot {:newRoot "$dedup"}}]))
+
+    ;; {:$group {:_id dollar (keyword field) {:$first dollar} :_history {:$addToSet "$_history"}}}
 
 (defn where
   [where]

(defn qount
  []
  [{:$count "count"}])

(defn dedup
  []
  [{:$group {:_id "$gid" :dedup {:$first "$$ROOT"}}}
   {:$replaceRoot {:newRoot "$dedup"}}])

(defn dedup-on
  [field]
  (let [path (dollar field)]
    [{:$group {:_id path :dedup {:$first "$$ROOT"}}}
     {:$replaceRoot {:newRoot "$dedup"}}]))

    ;; {:$group {:_id dollar (keyword field) {:$first dollar} :_history {:$addToSet "$_history"}}}

(defn offset
  [n]

   :toVertex to-vertex
   :from from
   :to to
   :fromDedup from-dedup
   :toDedup to-dedup
   :root root
   :dedup dedup
   :dedupOn dedup-on
