I guess you need [(< 0 ?p)]
to express a predicate, right now datascript thinks it's a rule expression.
https://docs.datomic.com/on-prem/query.html#expression-clauses
wondering if some one can help I am playing with datascript and the a bit confused on :db/ref if i query some thing that has a ref I get it returned as #:db{:id 1} can that not auro resolve back the attributes ?
(def schema {:type/id {:db/unique :db.unique/identity}
:product/id {:db/unique :db.unique/identity}
:product/type {:db/valueType :db.type/ref}})
(def conn (d/create-conn schema))
(d/transact!
conn
[{:type/id 1 :type/name "type 1"}
{:type/id 2 :type/name "type 2"}
{:product/id 1 :product/name "p1" :product/type [:type/id 1]}
{:product/id 2 :product/name "p2" :product/type [:type/id 2]}])
(d/q '[:find (pull ?e [*])
:where
[?e :product/id]] @conn)
That's my simple example which returns
0. [ { :db/id 4, :product/id 1, :product/name "p1", :product/type { :db/id 1 } } ]
I am wondering if I can make it return :type/name in the row and other type related attributes instead of :product/type {:db/id 1}
feel free to point me at docs, could be I have just been missing or mis understanding how it works
@oliver.marks I believe *
only gets all of the attributes one level deep. you could try playing around with something like:
(d/q '[:find (pull ?e [* {:product/type [*]}])
:where
[?e :product/id]] @conn)
(I haven’t tried that)
(I’m also not very good at datalog)
@lilactown spot on that's works perfectly 🙂