Hello
Can I do something better then this or-join
to create the ?in-cart?
value?
This do not look like right.
'[:find ?name ?in-cart?
:keys :item/name :item/in-cart?
:where
[?item :item/name ?name]
(or-join [?item ?in-cart?]
(and [_ :cart/item ?item]
[(ground true) ?in-cart?])
(and (not [_ :cart/item ?item])
[(ground false) ?in-cart?]))]
Full runnable example here
https://gist.github.com/souenzzo/ebd049a99443883ebab180ff019400baThis is what I would do. Why does it not look right?
I was going to suggest get-else as another possibility, but the reference is in the wrong direction
or > and // and not
feels to nested. Not sure if there is some missing?
or any other function to help
you could use a named rule, that would eliminate all the nesting
'[[(item-in-cart? [?item] ?in-cart?)
[_ :cart/item ?item]
[(ground true) ?in-cart?]]
[(item-in-cart? [?item] ?in-cart?)
(not [_ :cart/item ?item])
[(ground false) ?in-cart?]]]
… :where [?item :item/name ?name](item-in-cart? ?item ?in-cart?)
Rules can have the same name, then they will behave as a "or"? 😮 There is more examples/docs about this?
> Rules with multiple definitions will evaluate them as different logical paths to the same conclusion (i.e. logical OR). Here’s a rule, again from the Seattle example, which identifies communities that are “social-media”.
This was the only way to express “or” before or, and
etc were added
these are actually just syntax sugar for anonymous rules
(with gensym-ed names)
Am I doing something wrong? I want to retract all values of the group attribute:
(d/q '[:find ?group
:where [17592186048817 :group ?group]]
db)
=> #{[#uuid"5ede7e84-c6ac-4116-82d4-0f6dfae77b9d"]}
@(d/transact conn [[:db/retract 17592186048817 :group]])
Execution error (IndexOutOfBoundsException) at datomic.db.ProcessInpoint/inject (db.clj:2472).
Maybe double-check your version. This feature is relatively recent
you need those versions or greater
Ah, ok, we are using an older version, thanks much
Yup, that was it, thanks again.