我的数据库已经满了
(def fixtures [
[:db/add 0 :system/group :all]
{
:product/name "Donut Keurig"
:product/category "snack"
:product/brand "Grocery&GourmetFood"
:product/height "2.1"
:product/width "3.2"
:product/notes "The Original Donut Shop Keurig Single-Serve K-Cup Pods, Regular Medium Roast Coffee"
}
{
:product/name "Ferrero Rocher Hazelnut Chocolates"
:product/category "Candy"
:product/brand "Candy&Chocolate"
:product/height "3.4"
:product/width "2"
:product/notes "A tempting combination of smooth chocolaty cream surroiunding a whole hazelnut within a delciate, crisp wafer all enveloped in milk chocolate and finely chopped hazelnuts"
}
])
(def conn (d/transact! conn u/fixtures))
但告诉我这个错误:
未捕获的错误:断言失败:(conn?conn)在 Function.datascript.core.transact_BANG_.cljs$core$IFn$_invoke$arity$3
此外,我想像这样显示数据库的结果:
(defmulti read om/dispatch)
(defmethod read :product/name
[{:keys [state query]} _ _]
{:value (d/q '[:find [(pull ?e ?selector) ...]
:in $ ?selector
:where [?e :product/name]]
(d/db state) query)})
(defui product-view
static om/IQuery
(query [this] [{:product/name [:db/id :product/name]}])
Object
(render [this]
(let [{:keys [product/name] :as entity}
(get-in (om/props this) [:product/name ""])]
(dom/tr nil
(dom/td nil name)))))
(defui products-view
static om/IQuery
(query [this] [{:product/name [:db/id :product/name]}])
Object
(render [this]
(dom/table #js {:className "table table-bordered"}
(dom/thead nil
(dom/tr #js {:className "row-garden"}
(dom/th nil "Product Name")
(dom/th nil "Category")
(dom/th nil "Brand")
(dom/th nil "Height")
(dom/th nil "Width")
(dom/th nil "Notes")))
(dom/tbody
(let [{:keys [product/name] :as entity}
(get-in (om/props this) [:product/name ""])]
(println conn)
(dom/tr nil
(dom/td nil name)))))))
(om/add-root!
reconciler
products-view
(gdom/getElement "table-products"))
但不起作用:(
谢谢!