This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-28
Channels
- # aleph (10)
- # announcements (1)
- # aws-lambda (1)
- # beginners (162)
- # calva (81)
- # chlorine-clover (2)
- # cider (18)
- # clj-kondo (2)
- # cljs-dev (1)
- # cljsrn (12)
- # clojure (64)
- # clojure-australia (6)
- # clojure-europe (13)
- # clojure-nl (3)
- # clojure-sweden (26)
- # clojure-uk (36)
- # clojurescript (45)
- # community-development (10)
- # conjure (16)
- # core-logic (4)
- # cursive (6)
- # datascript (1)
- # emacs (1)
- # events (2)
- # fulcro (87)
- # girouette (5)
- # honeysql (4)
- # hoplon (3)
- # hugsql (3)
- # leiningen (8)
- # malli (18)
- # off-topic (33)
- # pathom (14)
- # reitit (5)
- # remote-jobs (1)
- # reveal (1)
- # shadow-cljs (50)
- # sql (3)
- # startup-in-a-month (1)
- # vim (5)
- # xtdb (30)
Does crux support return maps defined with :keys
like in https://blog.datomic.com/2019/06/return-maps-for-datomic-cloud-clients.html ?
Not currently, although I definitely see the merits and I added it as an idea on our backlog a while ago š In the meantime I suspect the DataScript implementation could be fairly easily adapted and used for Crux in userland https://github.com/tonsky/datascript/commit/5bc0b3e6090152d6cfd2726d3d92ddc821185cf7
There was also a Zulip thread where this was discussed once: https://juxt-oss.zulipchat.com/#narrow/stream/194466-crux/topic/Organizing.20Crux.20results
this might be of some use, if you hadn't already created your own version
(defn q2
"Decorate a supplied `q` call with return maps
Caveats:
- no error handling, simply reverts to default behaviour (return tuples)
- no enforcing of keys/syms/strs types
- does not ensure keys are unique
- not usable with `crux.api/open-q`
- a built-in implementation could probably be more efficient"
[qfn {:keys [find keys syms strs] :as query} & args]
(let [ks (or keys syms strs)]
(cond->> (apply qfn query args)
(and (vector? ks)
(= (count ks)
(count find)))
(map (partial zipmap ks)))))
;; e.g.
(q2 (partial crux/q (crux/db (crux-node)))
'{:find [e v]
:keys [:ent :val]
:where [[e :crux.db/id v]]})
;; => [{:ent 1 :val 1}]
We have just added it to master
so it will be in the next release š
https://github.com/juxt/crux/pull/1407
Poking at this, trying to figure it out on my own, but so far Iāve been unsuccessful.
Iām moving to Postgresql-backed datastore and txact store and Iām not clear on
a) whether Iām supposed to include com.opentable.components/otj-pg-embedded
in my deps (I think so, as it is clearly a pg driver but the docs on it are sparse and this statement of theirs confuses/concerns me: āExcellent for allowing you to unit test with a ārealā Postgres without requiring end users to install and set up a database cluster.ā)
b) again, as those OpenTable docs are a bit sparse, I donāt know what to provide for my :db-spec
values. Iāll be trying a few different url options but Iām not clear here.
I think Iāve found it. Had to search github for db-spec
in files named config.edn
.
Spoke too soon. Still not quite there.
Hey š we only use otj-pg-embedded
for testing - I don't know if it's feasible to use it in production without missing some critical features (e.g. backup/restore). What is your motivation behind wanting to use an embedded Postgres?
I donāt want to use an embedded Postgres.
Iām just following the guideā¦
where it says > Each of these also require an additional dependency to pull in the relevant JDBC driver - see the Crux JDBCĀ https://github.com/juxt/crux/blob/master/crux-jdbc/project.cljĀ for our latest dependencies.
The only postgresql-related dependency was the OpenTable library.
I got it. Also pushed a PR to the docs. Not sure thatās how it should be documented, but figured a first pass at it would be better than nothing. https://github.com/juxt/crux/pull/1403
Ahh, I see, yes you're perfectly correct about all that (sorry it wasn't explained!), and thanks for the PR š
Hey @U01GXCWSRMW - thanks for the PR š I'd prefer that we fix this in the project.clj
though - I suspect what's happened is that someone's changed the project.clj
to be suitable for dev without realising that the docs point to it
Makes sense, but would that require scaffolding (setting up and tearing down a PG instance) to then run the tests?
It would, but the test dependencies are handled independently in crux-test
's project.clj
. In crux-jdbc
they're marked as provided
dependencies, so they'll only be included automatically at dev-time
In short, let's update the dep there to the main Postgres dep - if need be, we can include the pg-embedded dep in the dev profile so that it's still included when developing crux-jdbc
(although the dev advice is to run the project from the root of the repo, which already includes the embedded dep)
Fun fact, there is no real way to figure out that the dependency is wrong because it does in fact write to the configured postgresql database. Ask me how I know!
Yeah. I saw that as well. š
I tested by replacing the dep, spinning up a second instance, and hey, there was my original data still there! I couldn't just read the database directly, it's opaque to me
@U050V1N74: I fell victim to this as well! I suspect you can safely close https://github.com/juxt/crux/issues/1364 and blame the dep