This commit is contained in:
Travis Shears 2025-06-05 16:07:22 +02:00
parent 8b266a036f
commit fc0dd204c7
4 changed files with 41 additions and 1 deletions

View file

@ -4,7 +4,12 @@
;; logging, required by jetty:
org.slf4j/slf4j-simple {:mvn/version "2.0.16"}
;; json decoding
;; 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
metosin/muuntaja {:mvn/version "0.6.11"}
;; routing:

13
src/snippets/config.clj Normal file
View 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
View file

@ -0,0 +1 @@
(ns snippets.core)

21
src/snippets/db.clj Normal file
View 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"}])])