 ;; -----------------------------------------------------------------------------
 ;; read
 
+(defn ds-parse [query]
+  (let [_ (debug "dslink query" query)]
+    (into []
+      (for [subq query]
+        (let [_ (debug "subq" subq)]
+          (if
+            (vector? subq)
+            (let [val `{~(first subq) [:db/id]}
+                  _ (debug "val" val)]))
+          )))
+    query))
+
 (defmulti read om/dispatch)
 
+(defmethod read :current-user
+  [{:keys [query state]} k p]
+  (let [_ (debug "read :current-user" query)
+        db @state
+        user (d/pull db '[*] )]
+    {:value user}))
 
 (defmethod read :default
   [{:keys [query state ast]} k _]

    :title "Baz"}
   {:db/id -4
    :email "bob.smith@gmail.com"}
   {:root  "my app root"
    :items [-1 -2 -3]
    :current-user -4}])

;; At this point, we could link the current-user entity to every item.

     ;; - rewrite db->tree for use with datascript
     ;; - rewirte d/pull to use the om.next patterns
     ;; - ?
     [{:db/id "1" :title "defaultish value"}]}))


;; -----------------------------------------------------------------------------
;; Components

(defui User
  static om/Ident
  (ident [_ {:keys [:db/id]}] id)
  static om/IQuery
  (query [_] [:db/id :email])
  Object
  (render [this]
    (let [{:keys [db/id email]} (om/props this)]
      ))
  )

(defui Item
  static om/Ident
  (ident [_ {:keys [:db/id]}] id)
  static om/IQuery
  (query [_]
    '[:db/id :title [:current-user _]])                     ;; NEW STUFF
  Object
  (render [this]
    (let [{:keys [db/id title current-user]} (om/props this)]
      (dom/li nil
        (dom/div nil (str id " - " title))
        (dom/div nil (:email current-user))))))

(def item (om/factory Item))
