sveri 2020-07-09T14:53:39.023400Z

Not with luminus and whatever sql client it uses. But I define these two functions:

sveri 2020-07-09T14:54:06.024Z

(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)})

sveri 2020-07-09T14:55:05.024400Z

And a query that uses postgres 12 functions looks like this:

(str "select jsonb_path_query_array(content, '$[*] ? ( == " id ")') as content from api_data
               where users_id = ? and spec_id = ? and component_path = ? and content @> '[{\"id\":" id "}]'")

sveri 2020-07-09T14:55:31.024900Z

Unfortunately I did not figure out yet how to do parameterized select with psql json queries.

sveri 2020-07-09T14:56:48.025200Z