Fork me on GitHub
#fulcro
<
2020-08-29
>
Michael W21:08:17

how to access the database from the repl using fulcro-rad? I want to create some new queries but want to play with them manually so I can see what I would get. Do I need to use the datamic library directly or can I get access to the database from the environment outside a resolver or mutation?

Tyler Nisonoff23:08:55

are you branched off of the rad demo? if you look at the demo, theres a ns com.example.components.datomic that has a (defstate datomic-connections ...) the development ns uses that to seed the db -- should be able to do something similar in the REPL or something to get a connection to the db you're using

Michael W22:08:15

I'm really confused actually. I used datomic.api, connected to my local datomic free, and I have the fulcro-rad demo running, but I can't seem to query for any of the idents. :invoice/id :item/name, :customer/name everything I try to query says the entity cannot be resolved. I can click in the demo app and see these things in the app, but trying to query datomic for them I get entity errors.

(d/q '[:find ?e :where [?e :customer/name "Sam"]] (d/db conn))
Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:79).
:db.error/not-an-entity Unable to resolve entity: :customer/name

pserrano23:08:11

Have you already transactioned the db schema?

Michael W23:08:33

Yes, it transacts the schema at app startup.

Michael W23:08:49

There is something going on in the fulcro-rad-datomic adapter that I don't understand to translate pathom queries to datomic, and I am not good enough at clojure to understand exactly what is happening.

pserrano23:08:51

Does pulls works?

pserrano23:08:50

Maybe this is not the correct conn

✔️ 3
Michael W23:08:49

Doh, thanks for the rabbit hole, apparently I had changes disabled in the config. It looked like it was transacting but it was not ever sending changes to the db.

Michael W23:08:12

:datomic/prevent-changes? false in the config fixed it.

✔️ 3
pserrano23:08:32

Could/Should I have a fn in my :shared app stuff? It would be a Html5History helper function used by every defsc component