 
 (defn view-model
   [model]
-  (let [cart-products (reaction (->> (-q model
+  (let [db (reaction (:db @model))
+        cart-products (reaction (->> (-q @db
                                          [:id :title :price :quantity]
                                          '[:find ?e ?t ?p ?q
                                            :where

                                       -format-price))
     :checking-out?      checking-out?
     :checkout-disabled? (reaction (or @checking-out? (empty? @cart-products)))
     :products           (reaction (->> (-q model
                                            [:id :title :price :sold-out?]
                                            '[:find ?e ?t ?p ?sold-out?
                                              :where

  (:require-macros [reagent.ratom :refer [reaction]]))

(defn -q
  "Queries Datascript db and returns result as a map with specified keys."
  [db keys q & args]
  (map #(zipmap keys %) (apply d/q q db args)))

(defn -format-price
  [price]
