Fork me on GitHub
#datomic
<
2015-07-31
>
raymcdermott14:07:35

quick question … can I filter datoms based on transaction data? I guess yes but is that via a standard query or do I have to write code?

raymcdermott14:07:58

in my use case, I have two transactions on the same data but would sometimes like to show the data back to the user based on the source system (tracked in the transaction)

tcrayford14:07:42

@raymcdermott: the transaction entities are perfectly queryable from normal queries

raymcdermott14:07:29

ok cool - that’s what I hoped but I cannot see any examples

tcrayford14:07:32

you just join against them via the part of the datom that is the transaction id simple_smile

raymcdermott14:07:14

ah - ok so I wouldn’t need to use the history view? Or maybe I would combine that?

raymcdermott14:07:12

I see the example

raymcdermott14:07:17

[:db/add #db/id[:db.part/tx] :data/src "http://example.com/catalog-2_29_2012.xml"]

raymcdermott14:07:48

so (just to nail it) I can just add :data/src to the query?

tcrayford14:07:29

you'd need to join against txid, but yeah

raymcdermott14:07:48

ah, ok and how would that work with pull?

potetm14:07:58

@raymcdermott: I believe It depends if the data you’re interested in is in the current db or not.

tcrayford14:07:09

(d/q '[:find ?src :where [_ :user/email _ ?tx] [?tx :data/src ?src]] …)

tcrayford14:07:51

with pull - I wouldn't be too surprised if it didn't work with transaction entities, or if they did. If they do, you'd probably just use the txid as the entity id

tcrayford14:07:23

(I'd have to try it at a repl, but I can't right now easily)

raymcdermott14:07:15

ok let me try and play over the weekend and I’ll come back here

raymcdermott14:07:32

thanks for the great guidance so far1