This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-18
Channels
- # admin-announcements (90)
- # alda (1)
- # aws (23)
- # beginners (60)
- # boot (217)
- # cljs-dev (20)
- # cljsjs (23)
- # cljsrn (85)
- # clojars (28)
- # clojure (101)
- # clojure-art (1)
- # clojure-berlin (10)
- # clojure-dev (16)
- # clojure-my (2)
- # clojure-russia (194)
- # clojure-sg (7)
- # clojure-ukraine (1)
- # clojured (1)
- # clojurescript (99)
- # clojurex (1)
- # community-development (6)
- # core-matrix (11)
- # cursive (26)
- # datomic (51)
- # euroclojure (30)
- # hoplon (560)
- # jobs (44)
- # ldnclj (34)
- # mount (23)
- # music (3)
- # off-topic (10)
- # om (145)
- # onyx (3)
- # perun (38)
- # portland-or (2)
- # proton (55)
- # re-frame (64)
- # reagent (26)
- # ring-swagger (3)
- # spacemacs (21)
- # sydney (3)
- # yada (1)
@raphael: it doesn't look like you're installing the :dialog/bubbles
attribute. Your tx map for the schema needs to include :db.install/_attribute :db.part/db
.
@robert-stuttaford: thanks that's a good start, it doesn't use components maybe I don't need them after all
@currentoor: datomic's caching should never have any notable impact on the app, except for memory pressure. Also a reminder that "it doesn't work" isn't a great bug report. What were you trying to do? What happened? What should have happened? Tell us a bit about your environment? (OS, Datomic version, JVM version)
currentoor: there are occsaionally issues when restoring a database on top of a version of the same database. Are you using the restore functionality?
Hi! I've dug around in the datomic query docs and various examples/tutorials but I'm unsure whether this is easily possible: Given a db and an entity, I would like to return a single boolean value if it has more than N references via a specific attribute.
Example: given a user with :user/friends
(a many ref attribute), return a boolean for whether the user is "popular" (i.e. has more than 2 friends. I can probably make it work using a custom aggregate function but I wonder if it's possible with built-in features?
@jannis: you can use a nested query/subquery to limit query results to a ref attribute with refs of a count greater than some number, that’s pretty much what’s going on in the second query here - https://groups.google.com/forum/#!msg/datomic/5849yVrza2M/31--4xcdxOMJ-- re: returning a single boolean, I think I’d just handle that outside query. I.e., the query returns something in the results or it does not.
(the second query from the link)
(d/q '[:find ?track ?count
:where [(datomic.api/q '[:find ?track (count ?artist)
:where [?track :track/artists ?artist]] $) [[?track ?count]]]
[(> ?count 1)]]
(d/db conn))
I want to try doing it inside the query. (My goal is to have a declarative, query-based way of describing data derived from entities.)
https://gist.github.com/Jannis/8fd22f556b55f02589bf - this almost works, except for when no friends are set.
@jannis: ah, aggregates in find won’t get called if there are no results, you could look at using http://docs.datomic.com/query.html#get-else maybe
in body
oh wait card many attribute
So if I'd simply want to query the number of friends with :find (count ?f) .
, it would return nil
and not 0
if there are no friends?
that’s correct,
@jannis here’s one, but it’s a hack (against mbrainz sample)
(defn prolific [tracks]
(> (count (filter #(not= :nil %) tracks)) 500))
(d/q '[:find (user/prolific ?t) .
:in $ ?a
:where
(or [?t :track/artists ?a]
(and
[(missing? $ ?a :track/_artists)]
[(ground :nil) ?t]))]
(d/db conn)
1111) ;;no tracks for non-existent artist
;17592186046909) ;pink floyd - works for true condition in artist
Nice job. Yes, it may be a hack but I played with or
and ground
as well and couldn't get anything to work. This is still reasonably readable.
I have to give credit to @marshall for suggesting that use of or
, missing?
, and ground
to me.
@tcrayford: My apologies. I was having the same issue as @domkm, same codebase. Namely we have this rule. https://clojurians.slack.com/files/domkm/F0JJN0G9X/rules.clj And it sporadically results in this exception. https://clojurians.slack.com/files/domkm/F0JJMNC65/-.txt
Hello, what the difference between (d/tempid :db.part/db) and #db/id[:db.part/db] ? thank a lot
@raphael: you would use the former in code, and the latter in a data structure to be read (like an edn file)
I'm on the Datomic Pro Starter license and it ways I get to have to 2 peers + 1 transactor. I was wondering if it is ok for me to have a staging environment with that the same setup and production environment as well, so 4 peers and 2 transactors total (albeit two separate apps).
Or does that violate the license?
@currentoor: That is perfectly acceptable. The process limit specifically refers to production processes. You’re permitted to maintain separate unlimited development/staging instances.
Awesome, thanks @marshall!
What can lead to this error? java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :user/email
?
worth mentioning: recently there was someone who missed the :db.install/_attribute :db.part/db
part of the schema installation. that's a hard one to see.
Nope, that's there. The schema is generated by datomic-schema
. But it's not current transacted into the db apparently. I'll dive deeper.
Oh, (d/transact ...)
not @(d/transact ...)
, so my guess is since it was never deref'd it didn't run at all?
Ah! Excellent, it is working now. There was an error: :db.type/int
doesn't exist, I should be using :db.type/long
.
I hit another problem: Exception in thread "async-dispatch-5" java.lang.IllegalStateException: :db.error/connection-released The connection has been released.
inside (d/db conn)
.
@jannis: that’s likely. Or a different thread releases the connection through a call to release, or memory issues/gc on peer or transactor cause excessive latency and peer loses connection, etc. (or genuine network partition), etc.
Oh, I know what it is. My process terminates while a go
loop is still busy and tries to access a conn/db.
yep, that would do it.
Datomic caches connections, so successive connect calls, etc. are usually not an issue.
if you’re interested in more discussion re: managing connections, I think Ryan’s blog post here is pretty good: http://www.rkn.io/2014/12/16/datomic-antipatterns-eager-conn/