3 ms·
Looks interesting! Was Crux an easy choice? Did you consider any other databases (non-Datalog)? Or Datahike?
by dorian-graph 6y ago
Looks interesting! Was Crux an easy choice? Did you consider any other databases (non-Datalog)? Or Datahike?
- jacobobryant 6y agoCrux was a pretty straightforward choice. Didn't really consider any non-datalog DBs. I've used Datomic quite a bit, but preferred crux since it's open source, has filesystem persistence and doesn't require a separate process for the transactor (nothing wrong with Datomic's choices; the tradeoffs just make it unsuitable for Biff). I went with crux over datahike since it's more mature and has postgres persistence (and Kafka persistence, not that I need that yet). I haven't actually used the bihemporality features of crux yet, but maybe they'll come in handy.
- dorian-graph 6y agoThat makes sense to me. I've been trying to decide out of Crux or Datahike for a side project. I was leaning towards Datahike because I didn't like the idea of having to do a full document update like you do in Crux, but I need to dig into it a bit more.
- jacobobryant 6y agoAre you concerned about that for performance reasons or for ease-of-use reasons? To address the latter, I made a separate transaction format for Biff that allows merging (it's similar to Firebase's transaction format). So e.g. {[:users #uuid "some-user-uuid"] {:db/merge true :username "foo"}} gets converted to [[:crux.tx/put (merge (crux/entity db #uuid "some-user-uuid") {:username "foo"})]] There is a race condition though; if another tx updated that document after the crux/entity call but before `:username "foo"` was written, then that tx would get clobbered. I'm planning to add `:crux.tx/match` operations automatically to prevent that from happening. There was talk on #crux in Clojurians slack today of using the newly-added transaction function feature to do merges. Haven't looked into that myself.
- dorian-graph 6y agoJust for ease-of-use. In Datomic/Datahike you can update a single datom/fact. I'll have to look into making some similar sort of helpers for what you've done.
- ribelo 6y agohttps://opencrux.com/docs#_transaction_functions https://opencrux.com/docs#_transaction_functions ``` (crux/submit-tx node [[:crux.tx/put {:crux.db/id :crux.fn/assoc :crux.db/fn '(fn [ctx eid k v] (let [db (crux.api/db ctx) entity (crux.api/entity db eid)] [[:crux.tx/put (assoc entity k v)]]))}]]) (crux/submit-tx [[:crux.tx/fn :crux.fn/assoc doc-id k v]]) ```