add xtdb
This commit is contained in:
parent
8b266a036f
commit
fc0dd204c7
4 changed files with 41 additions and 1 deletions
5
deps.edn
5
deps.edn
|
|
@ -4,6 +4,11 @@
|
||||||
;; logging, required by jetty:
|
;; logging, required by jetty:
|
||||||
org.slf4j/slf4j-simple {:mvn/version "2.0.16"}
|
org.slf4j/slf4j-simple {:mvn/version "2.0.16"}
|
||||||
|
|
||||||
|
;; db
|
||||||
|
com.xtdb/xtdb-api {:mvn/version "2.0.0-beta9"}
|
||||||
|
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1002"}
|
||||||
|
org.postgresql/postgresql {:mvn/version "42.7.6"}
|
||||||
|
|
||||||
;; json decoding
|
;; json decoding
|
||||||
metosin/muuntaja {:mvn/version "0.6.11"}
|
metosin/muuntaja {:mvn/version "0.6.11"}
|
||||||
|
|
||||||
|
|
|
||||||
13
src/snippets/config.clj
Normal file
13
src/snippets/config.clj
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
(ns snippets.config)
|
||||||
|
|
||||||
|
;; (require '[environ.core :refer [env]])
|
||||||
|
(defn get-config [] (read-string (slurp "config.edn")))
|
||||||
|
|
||||||
|
;; (def config
|
||||||
|
;; (merge
|
||||||
|
;; (read-string (slurp "config.edn"))
|
||||||
|
;; {:db {:host (env :db-host)
|
||||||
|
;; :port (Integer. (env :db-port))
|
||||||
|
;; :user (env :db-user)
|
||||||
|
;; :password (env :db-password)
|
||||||
|
;; :dbname (env :db-name)}}))
|
||||||
1
src/snippets/core.clj
Normal file
1
src/snippets/core.clj
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
(ns snippets.core)
|
||||||
21
src/snippets/db.clj
Normal file
21
src/snippets/db.clj
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
(ns snippets.db
|
||||||
|
(:require
|
||||||
|
[snippets.config :as config]
|
||||||
|
[xtdb.api :as xt]))
|
||||||
|
|
||||||
|
(def client
|
||||||
|
(let
|
||||||
|
[c (:xtdb (config/get-config))]
|
||||||
|
(xt/client
|
||||||
|
{:host (:host c)
|
||||||
|
:port (:port c)
|
||||||
|
:user "xtdb"
|
||||||
|
;; :password "xtdb"
|
||||||
|
:dbname "xtdb"})))
|
||||||
|
|
||||||
|
(defn uuid [] (str (java.util.UUID/randomUUID)))
|
||||||
|
|
||||||
|
(defn save-snippet [snippet]
|
||||||
|
(xt/execute-tx client [[:put-docs :snippets (merge snippet {:xt/id (uuid)})]]))
|
||||||
|
|
||||||
|
;; (xt/q client ['(from :users [{:name "travis"}])])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue