Fork me on GitHub

nothing, carry on


learning datomic right now 😛


Is … is this magic?: :find ?composition-entity (distinct ?radical) ?author-name does what I want: returns a seq of [id [list of radicals] author-name]


I feel like a noob again wondering how for loops work 🙃, because before, with just :find ?composition-entity ?radical ?author-name, DataScript returned a big fragmented set of [id single-radical author-name] vectors, and I thought I'd have to do a group-by outside the query. But throw in a distinct in there (I'm a big boy now, reading datomic docs) and I feel like the computer read my mind and gave me exactly what I wanted. Spooky.


How do I use transactor functions? I have a simple function that I want to call in a transaction, that for now just adds a new author with a given name: (defn my-trans-fn [db & [author-name]] [:db/add -1 :author/name (or author-name "test-1")]). I've tested this function in a non-transactional way like so: (d/transact! conn [(my-trans-fn nil "foo")]) and it inserts a new entity as expected. Now, I'd like to call this inside a proper transaction, but (d/transact! conn [[:db.fn/call my-trans-fn "bar"]]) doesn't seem to be valid?


Do I need to "load" the transactor function into the db, like with Datomic? Do I need to quote my-trans-fn somehow?


The error I get: Bad entity type at :db.fn/call, expected map or vector


And similar if I leave out a pair of brackets around that :db.fn/call


Holy cow, I magically landed on at the right minute when Nikita started typing a transactor function! At 45:50 I see my problem: my function's returned vector needed another level of nesting, hmm