Fork me on GitHub
#datomic
<
2021-09-20
>
Maravedis08:09:40

Hello. I have a noob problem but I'm not really having luck reading the documentation: I just want to pull all the datoms of a transation. How do I do that?

andrioni09:09:25

tx-range is probably going to be better in this case

Maravedis10:09:19

I found tx-range and tx-data and it was exactly what I needed 🙂 Thanks.

Maravedis08:09:46

Today I'm doing:

(d/q '[:find ?pl ?v ?added
                 :in $ ?tx
                 :where
                 [?pl :purchase-line/quantity-received ?v ?tx ?added]]
      (d/history db) transaction-id)
and it's terribly inneficient (like 20s).

Lennart Buit10:09:48

so; there is no index on t (or tx). Running this query, datomic has no choice but to use AEVT or AVET indices. Effectively walking through the index for that attr, for each point in time.

Lennart Buit10:09:18

since you bind ?tx in your in, consider using (d/as-of db transaction-id)

Lennart Buit10:09:38

or otherwise, you can probably also use d/tx-range to get that specific transaction from the log

Lennart Buit10:09:07

Does that make sense?

Maravedis14:09:27

It makes sense. Thanks for your help 🙂

greg17:09:59

How to retract mistakenly added :db/ident? E.g. i added such a transaction by mistake:

(d/transact conn {:tx-data [{:db/ident :release.type/album :release.type/name "Album"}]})
How to retract it so :release.type/album is not longer available in the latest db:
(d/q '[:find ?e :where [?e :db/ident :release.type/album]] db) ;; => ()

keymone17:09:37

trying to understand the difference between lookup refs and unique identity (reading https://docs.datomic.com/on-prem/schema/identity.html#lookup-refs), is there a difference between upserting

{:person/email ""
 :person/loves :pizza}
versus
{:db/id [:person/email ""]
 :person/loves :pizza}
?

Lennart Buit18:09:14

I think the second will raise when is not in your db

Lennart Buit18:09:15

Yeah it does, so the first is a proper upsert, the second can only update