This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-09
Channels
- # announcements (2)
- # babashka (33)
- # beginners (122)
- # bristol-clojurians (1)
- # calva (6)
- # chlorine-clover (3)
- # cider (45)
- # clara (10)
- # clj-kondo (3)
- # cljsrn (17)
- # clojure (80)
- # clojure-dev (21)
- # clojure-europe (86)
- # clojure-italy (5)
- # clojure-japan (5)
- # clojure-losangeles (7)
- # clojure-nl (5)
- # clojure-portugal (3)
- # clojure-uk (31)
- # clojurescript (30)
- # conjure (4)
- # core-async (29)
- # cursive (20)
- # data-science (25)
- # datomic (7)
- # duct (17)
- # figwheel-main (73)
- # fulcro (23)
- # jobs-discuss (36)
- # juxt (5)
- # kaocha (2)
- # lambdaisland (6)
- # luminus (5)
- # malli (17)
- # mount (10)
- # music (7)
- # off-topic (16)
- # re-frame (30)
- # ring (17)
- # rum (1)
- # shadow-cljs (10)
- # spacemacs (10)
- # specmonstah (4)
- # sql (45)
- # tools-deps (21)
- # xtdb (20)
Not with luminus and whatever sql client it uses. But clojure.java.jdbc I define these two functions:
(defn- to-pg-json [content]
(doto (PGobject.)
(.setType (name :jsonb))
(.setValue (json/write-str content))))
(defn read-json-b
[^PGobject x]
(when-let [val (.getValue x)]
(json/read-str val)))
and then call it like this:
(j/insert! db :api_data {:users_id users-id :spec_id spec-id :component_path component-path
:content (to-pg-json content)})
And a query that uses postgres 12 functions looks like this:
(str "select jsonb_path_query_array(content, '$[*] ? (@.id == " id ")') as content from api_data
where users_id = ? and spec_id = ? and component_path = ? and content @> '[{\"id\":" id "}]'")