Fork me on GitHub
#datomic
<
2021-02-14
>
lispers-anonymous04:02:04

Is it possible to pass rules to a https://docs.datomic.com/cloud/query/query-data-reference.html#q in datomic cloud? Example in thread Edit: I think I figured it out. I also posted my conclusions in the thread.

lispers-anonymous04:02:34

When I try it I get an exception that says

Unable to resolve symbol: % in this context
A really simplified case looks something like this
(d/q '[:find ?t ?thing-count
       :in $ %
       :where
       [?t :thing/id ?id]
       [(q '[:find (count ?t)
             :in $ %
             :where
             (active-thing ?t)]
           $ %)
        [[?thing-count]]]
       [?t :thing/color "blue"]]
     db rules)
I've tried shuffling around just passing in $, not using :in in the nested query, adding quotes in different places, using the map form of a query for the nested q . Nothing has worked so far.

lispers-anonymous04:02:59

As soon as I got this posted I figured it out. I can just bind the rules to a symbol like ?rules and pass it in that way. For the curious, it looked something like

(d/q '[:find ?t ?thing-count
       :in $ ?rules
       :where
       [?t :thing/id ?id]
       [(q '[:find (count ?t)
             :in $ %
             :where
             (active-thing ?t)]
           $ ?rules)
        [[?thing-count]]]
       [?t :thing/color "blue"]]
     db rules)

thanks2 2
lispers-anonymous04:02:26

I can't use the rules in the top level of the query when it's bound to ?rules. But I can pass in the same set of rules twice, and bind one at the top level % and the other to ?rules. What a trip!

😲 3
joe smith18:02:16

I am thinking of using Google Firebase to power authentication and store user data for Android, iOS. For financial data (deposits, wallet balance) I am going to use Datomic on AWS. I would like to use Firebase for rapid realtime response but datomic as an "ultimate authority of truth". ex) Firebase shows deposits instantly. but this is not reflected in Datomic yet. Is this a viable strategy? syncing firebase and datomic somehow? or Should I be using Datomic always? Read data, write data to datomic without relying on Firebase? It might be slow at some point if there are lot of writes (I read Datomic isn't built for large volume of writes) and I'm afraid that it might impact the user experience on mobile app side. I am trying to justify using Datomic to my team. Since we are dealing with real money, we need an immutable log, and ability to look at snapshots of the past, meet regulations but overall concerned about the impact of network performance that might trickle to the end user (as a result of calling datomic on AWS api gateway/lambda from google firebase cloud functions)