Fork me on GitHub
#datomic
<
2017-03-22
>
djjolicoeur01:03:26

this is probably a silly question but if I have a fn that transacts, then derefs the future of the transaction, and then calls datomic.api/db on the db connection, is that call to datomic.api/db guaranteed to reflect a db value consistent with the tx, or would I need to use the db-after from the transaction to ensure the tx is reflected in the db value? for instance (defn test-tx [tx-data] @(d/transact (:conn db) tx-data) (d/db (:conn db)))

djjolicoeur01:03:29

I generally use db-after, but wondering if that is strictly necessary

favila01:03:08

Db-after is the db immediately after the tx. D/db is some db after the tx (could possibly be after other later txs). The fact that the deref completed means that tx is now visible to the peer and any d/db on that peer will now include it @djjolicoeur

marshall01:03:22

@djjolicoeur assuming the txn is successful. If it fails or times out your call to d/db might still succeed (depending on how you handle, or don't handle, the failure)

marshall01:03:39

Timed out or failed txn will throw when you dereference the future http://docs.datomic.com/clojure/#datomic.api/transact

djjolicoeur01:03:34

thanks @favila @marshall wasn’t sure, assuming a successful tx, whether the the peer was guaranteed to reflect that tx when a value was requested. I generally use db-after anyways to isolate from other tx’s in the system anyways, but we were having a discussion in the office today and I wasn’t sure on whether it was strictly necessary.

rauh10:03:46

@dominicm You mean in the result of this query? Yes, there is no such attribute, it's just the e in the eavt indices.

rauh10:03:06

@dominicm Also count an entity, and you won't see ;db/id counted, or seq it. It's a special field in the entity.

rc114011:03:51

hi all , is it possible to rename a field when using the pull api , i am fetching deeply nested data and would like to alias it , the nested value is returned something like {:person {:company {:location "somewhere}}} , when accessing the pull'd data i would prefer to access person-location instead of (:location (:company (:person data))) , hope that makes sense

favila15:03:24

@rc1140 pull can only do two transformations: limit cardinality-many results, and default cardinality-one values

rc114015:03:48

thanks , saw that in the docs , just wanted to make sure didnt miss something obvious

favila15:03:39

@rc1140 you can assert :person-location as another ident for the same attribute

favila15:03:49

that may work

favila15:03:55

but it's a really bad idea

rc114015:03:56

not sure i follow what you mean ?

favila15:03:14

when you assign an ident, the old ident still works

favila15:03:26

(until the old ident is assigned to something else)

rc114015:03:55

right , i get why that would be a bad idea as well , im happy doing a long form extraction out of the map for now

favila15:03:56

ah, nevermind, I misunderstood the transform you want

favila15:03:11

you actually want to collapse levels

rc114015:03:30

using threading makes it a little less painful atm

favila15:03:07

If you are unfamiliar with the clojure.,walk namespace, it is very handy for post-processing pull expression results

rc114015:03:05

not familiar with it , but will go read up on it , any links you have on hand that you think would be a good intro

rc114015:03:42

have never seen that style of using the pull api before

rc114015:03:12

using d/pull and then passing it to the walk stuff , i have only using the pull api by calling d/q and then passing in i a query vector

uwo19:03:02

vague question here. using the tx-pipeline from best practices (http://docs.datomic.com/best-practices.html#pipeline-transactions) i’m getting clojure.lang.PersistentArrayMap cannot be cast to java.util.List. I can see that I’m passing a map to transactAsync within the pipeline, but I would expect that to work. Does this sound familiar to anyone?

uwo19:03:23

nvm. I see what I did wrong !

favila19:03:17

transactions can never be maps

favila19:03:33

an item in a transaction can be a map

uwo19:03:43

yeah, I’m wishing I would delete that embarrassing question … but it’s good to humble oneself periodically

souenzzo20:03:26

Hi, there is some way to same datomic's :db/txInstant in other atribute? (Example: I want to save {:db/id (d/tempid :db.part/user) :msg/txt "Hello" :msg/inst <#C03RZMDSH|datomic>/inst})

souenzzo20:03:50

Yes, I now that I can make a query where [?msg-id :msg/txt _ ?tx][?tx :db/txInstant ?v], but it's the only way?

favila20:03:32

@souenzzo You can't know the time a transaction completes until it completes?

timgilbert20:03:08

You can get the current datomic t value (before your transaction) by calling (d/basis-t db)

timgilbert20:03:59

...which would give you "transaction before this one" as a potential (d/as-of) target for historical data

timgilbert20:03:21

(Assuming that no other new data is transacted from a different process in between the time your call to (d/db conn) completes and when your {:msg/txt "Hello"} transaction completes)

souenzzo20:03:04

(clj-time.core/now) will do for now

timgilbert20:03:30

Good idea 😉