Fork me on GitHub
#datomic
<
2021-11-21
>
Benjamin13:11:26

(let [already? (into
                  #{}
                  cat
                  (d/qseq
                   '[:find ?key
                     :where
                     [_ :airstats.jira.ticket/key ?key]]
                   (d/db @conn)))])

  (defn already?
    [db key]
    (d/pull
     db
     '[:db/id]
     [:airstats.jira.ticket/key key]))
which is better? the use case is to check if some ticket key is already in the db. So I don't assert it twice

thumbnail15:11:40

If you make the ticket key unique asserting twice will not work (or work as an upsert). The advantage of that is that it's atomic :)

Benjamin18:11:06

https://docs.datomic.com/cloud/best.html#set-txinstant-on-imports what does it mean for txInstant to be newer than the transactors clock time? The second sentence seems to imply I shouldn't choose dates from the future else it needs to catch up.. ?

thumbnail20:11:15

That's right, but it is possible to set a txInstant in the past (as long as there's no newer datoms present). As an example, we used it for an initial ETL job to instead of a created-at attribute

✔️ 1