asami

Asami, the graph database https://github.com/threatgrid/asami
indy 2021-04-02T07:39:17.185700Z

Couldn't find something like a https://github.com/tonsky/datascript/blob/eb8ba4cd7217640b282a25ca2adda93183a9a4cf/src/datascript/core.cljc#L564 in Asami, the datascript implementation looks straightforward. I'm planning to use Asami with re-frame in the browser and kind of require this. Is this something word adding to Asami?

indy 2021-04-02T07:53:00.185900Z

I might be wrong but I think Asami's query optimizer might really shine with re-frame, since on every single transact (any state change of the app-db), all http://day8.github.io/re-frame/subscriptions/#why-layer-2-extractors will run and query the db.

2021-04-02T07:54:18.186400Z

the problem with asami is that it is designed for reading, not writing. transactions are deadly slow

2021-04-02T07:55:58.186600Z

it could rather be alongside db in re-frame, but not really as a replacement

2021-04-02T07:57:45.186800Z

then there is no need to refresh the views in case of transactions, because it is better not to do too many transactions. Even if you would like to, the time saved by the planner will be wasted

indy 2021-04-02T08:01:05.187Z

Oh okay, didn't know that Asami is designed primarily for reading. Thanks 👍:skin-tone-4:

2021-04-02T08:02:16.187200Z

It all depends on what kind of data you have and how fast it changes

2021-04-02T08:03:07.187400Z

adding 20k entities to asami takes 2500ms where datascript needs 1500ms

2021-04-02T08:05:08.187600Z

If you need to retrieve data from BE and display it to the user using complex queries, then asami is much better than anything else.

indy 2021-04-02T08:07:08.187800Z

I wanted asami to replace the global atom in re-frame. Which means it would be transacted upon on almost every kind of user interaction. Maybe a max of 30 transactions per second (naive figure after checking my redux dev tools for how many max actions are usually dispatched per user interaction)

2021-04-02T08:07:31.188Z

if you want to keep a small amount of data that you operate on frequently, I recommend that you see how fulcro does it. There is a lot going on around this topic, a solution you can use in re-frame is autonormal

2021-04-02T08:07:44.188200Z

https://github.com/lilactown/autonormal

indy 2021-04-02T08:09:21.188500Z

Great, my main intention was to keep the app db normalized, and the autonormal library might be what I am looking for

2021-04-02T08:09:30.188700Z

pull syntax/`eql` does not give you the same power as datalog, but it is usually sufficient

2021-04-02T08:11:17.188900Z

if you already have a normalized DB that is as flat as possible, a good solution for more complex queries is a meander

2021-04-02T08:11:24.189100Z

https://github.com/noprompt/meander

👍 1
indy 2021-04-02T08:11:39.189400Z

Yeah, I've dabbled with fulcro, kind of liked how the component was "hooked" to the app db using the EQL graph query, but felt the API surface layer was too big and the code didn't feel "neat"

2021-04-02T08:12:55.189600Z

I also much prefer the re-frame, and have made many approaches to fulcro in my spare time. it's big and clunky, but solves many problems.

2021-04-02T08:13:42.189900Z

here you can find an example how to mimic datascript using meander

indy 2021-04-02T08:15:18.190400Z

(reading through meander's README)

2021-04-02T08:17:25.190700Z

I have to go

2021-04-02T08:17:31.190900Z

good luck!

indy 2021-04-02T08:23:45.191200Z

Thanks a lot ribelo, that was of great help!