3
給定datascript分貝的這些定義,爲什麼此查詢不返回結果?
(def schema
{:tag/name { :db/unique :db.unique/identity }
:item/tag {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
:outfit/item {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}}
)
(defonce conn (d/create-conn schema))
(defn new-entity! [conn attrs]
(let [entity (merge attrs {:db/id -1})
txn-result (d/transact! conn [entity])
temp-ids (:tempids txn-result)]
(temp-ids -1)))
(defonce init
(let [tag1 (new-entity! conn {:tag/name "tag1"})
item1 (new-entity! conn {:item/tag tag1})
outfit1 (new-entity! conn {:outfit/item item1})]
:ok))
如果我運行這個devcard,我沒有得到任何結果:
(defcard find-by-tag-param
"find items by tag"
(d/q '[ :find ?item
:in ? ?tagname
:where
[ ?tag :tag/name ?tagname ]
[ ?item :item/tag ?tag ]]
@conn "tag1"))
爲什麼這個查詢沒有結果?