the other day i asked about how to audit which query rules are satisfied and favila had a nice suggestion to use ground
to return some known value. that works when my "top level" rule returns a grounded value, however i'd like to also audit nested rules as well. any idea how i can aggregate some grounded values from each rule?
here is a non-working example that returns an empty result because i think the bound value of ?rule
in the parent rule fails to unify on the different bound values in the nested rules.
(let [rules '[[(is-blue ?item ?rule)
[(ground :is-blue) ?rule]
[?item :item/color "blue"]]
[(is-in-stock ?item ?rule)
[(ground :is-in-stock) ?rule]
[?item :item/inStock? true]]
[(blue-items-in-stock ?item ?rule)
[(ground :blue-items-in-stock) ?rule]
(is-blue ?item ?rule)
(is-in-stock ?item ?rule)]]]
(d/q '{:find [?item (distinct ?rule)]
:in [$ %]
:where [(blue-items-in-stock ?item ?rule)]}
(d/db conn) rules))
=> []
ideally i would end up with something like this:
=> [[92358976734084 #{:blue-items-in-stock :is-blue :is-in-stock}]]
well this is exactly what i was looking for. thank you @lanejo01!
NP, I just wish I would have thought of it sooner đ . Definitely could have used this over the years.
> [?item :item/inStock? true ?rule]
is that 4th element intended?
oops, that was just a typo in the example. thanks for pointing it out.
1đNo, itâs an address, addresses can change.
Use clojure to construct the query as data
(defn query-players
[db rules player-name wants-is-player-rule?]
(->
(cond->
'{:find [?player]
:in [$ % ?player-name]
:where [[?player :player/name ?player-name]]}
wants-is-player-rule? (update :where conj '(?is-player ?player)))
(d/q db rules player-name)))
(query-players (d/db conn) the-rules "player1" true)
Oh interesting. When does it change at the moment? Whatâs the migration strategy to go from one format to another?
At the moment it doesn't, but you asked if you can rely on the endpoint address "ALWAYS" following that format.
I see. If it were to change, how could that be done safely?
Itâs just a different string. What if the endpoint had a uuid in it? Iâm not sure what you mean by âsafelyâ.
If it were to change, client applications would need to know about which endpoint to point to. By safely I mean informing the client application which endpoint it should use before and after the switch.
âClient applicationsâ meaning not ions?
Correct
How do they know what endpoint to hit right now?
Statically defined string at startup. Seems like a switch of that endpoint would be require application downtime.
Doubtful. That statement is only true because you arenât using a mechanism to dynamically update that endpoint and the datomic client using it.
Imagine switching the query groups your client applications point to with zero downtime. How would you do it?