This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-17
Channels
- # admin-announcements (4)
- # aws (26)
- # beginners (88)
- # boot (132)
- # cljs-dev (4)
- # cljsrn (35)
- # clojars (11)
- # clojure (41)
- # clojure-art (33)
- # clojure-austin (1)
- # clojure-chicago (4)
- # clojure-dev (3)
- # clojure-russia (2)
- # clojured (3)
- # clojurescript (9)
- # community-development (19)
- # datomic (34)
- # devcards (2)
- # editors-rus (4)
- # hoplon (29)
- # leiningen (4)
- # music (2)
- # off-topic (21)
- # om (69)
- # other-lisps (1)
- # perun (6)
- # re-frame (1)
- # reagent (9)
- # spacemacs (3)
- # yada (13)
I’m fiddling around with trying to obtain transaction events using the tx-report-queue facility and seeing some odd behaviour….
(save-new-cart conn {:cart/name "Cart-2"})
=> {:db/id 17592186045484, :cart/name "Cart-2"}
(def txns (d/tx-report-queue conn))
=> #'shopping-cart-demo.datomic/txns
txns
=>
#object[java.util.concurrent.LinkedBlockingQueue
0x418201de
"[{:db-before [email protected], :db-after [email protected], :tx-data [#datom[13194139534379 50 #inst \"2016-01-17T10:26:25.862-00:00\" 13194139534379 true] #datom[17592186045484 64 \"Cart-2\" 13194139534379 true]], :tempids {-9223350046623220289 17592186045484}}]"]
(d/pull (:db-after txns) '[*] 17592186045484)
NullPointerException datomic.api/pull (api.clj:162)
(d/remove-tx-report-queue conn)
=> nil
(def conn (d/connect uri))
=> #'shopping-cart-demo.datomic/conn
(d/pull (d/db conn) '[*] 17592186045484)
=> {:db/id 17592186045484, :cart/name "Cart-2"}
the save-new-cart resolves the tempid so I can see the entity that was created and of course that agree with the data in the txns queue
but when I come to query it, I get a NPE … and I then reconnect to the DB and the data is there
It seems like the :db-after is not null, the entity ID is not null so something weird is going on
I am running the peer lib and transactor from datomic-pro-0.9.5327 starter edition
maybe I shouldn’t use the data like this so any advice on how I can retrieve the data for the transaction from the queue would be great!
[my goal, perhaps obviously, is to watch the DB and generate changed data out to other systems]
I am wondering, is it possible to use aggregates in a where clause to answer a question like: what is the newest entity of a given type, and then use that entity to join some other stuff in the same query
if I want to keep the position of each element in a component list do I need a position attribute or is the list of element already ordered ? I want to have an ordered list of requests for each scenario with the following schema :
@yenda, see http://dbs-are-fn.com/2013/datomic_ordering_of_cardinality_many/
@casperc, as aggregates are declared at the :find level, that’s not possible in a single query. however, you can nest queries! [(datomic.api/q [… query with aggregates ...] $ ?something) ?something-else]
. good to do this if the subquery isn’t likely to be reused, otherwise probably better to make it a separate fn and compose
@robert-stuttaford: Woah, I did not know you can nest queries!
@robert-stuttaford: That could be the way to go, if aggregates can indeed answer the first part of the question, e.g. give me the entity with the biggest of some value. I’ll need to play around with it
let me know if it solves it for you
@robert-stuttaford: Will do. Still trying to sort it out, but an aggregate can definitely answer the first part of the question, so just need to grok completely how subqueries work
@raymcdermott: I think the problem is that you're treating txns
like it's a record with a :db-after
key. But it's not that - it's a LinkedBlockingQueue with a record inside it.
@raymcdermott: you want something like (d/pull (:db-after (.take txns)) '[*] 17592186045484)
, if I remember that api right
@bhagany: ok, thanks I didn’t find any good examples with tx-report-queue directly so I’ll check out the LBQ
@bhagany: that works a treat - thanks!!
I guess people use core.asynch or something similar to manage the events
bit of a shame that day of datomic etc. does not have some examples of this functionality … I will play around with it and make a blog post
@isaac: memcached is a much better cache for datomic's purposes. It scales multicore whereas redis is limited to one. Given that datomic only uses it's cache for k/v writes with bytes in each, it doesn't need any of the features of redis
Ah sorry, I received this error: IllegalArgumentExceptionInfo :db.error/not-an-entity Unable to resolve entity: :dialog/bubbles datomic.error/arg (error.clj:57)
Is there a way to invalidate the caching in Datomic in dev?
In the peer and anything potentially lingering in the transactor?
I’m seeing sporadic issues when trying to load seed data in dev. I’ve tried deleting the database and restarting both the transactor and the JVM but loading seed data still fails sometimes.