Skip to content

Commit

Permalink
use ulid instead of uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
daaku committed Jan 28, 2022
1 parent cd2df29 commit b803777
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(defproject org.clojars.daaku/sqjson "0.3.0"
(defproject org.clojars.daaku/sqjson "0.4.0"
:description "Treat SQLite as a JSON DB."
:url "https://github.com/daaku/sqjson-clj"
:scm {:name "git" :url "https://github.com/daaku/sqjson-clj"}
:license {:name "MIT License"}
:dependencies [[com.github.seancorfield/next.jdbc "1.2.761"]
[metosin/jsonista "0.3.5"]
[org.clojars.daaku/ulid "0.1.0"]
[org.clojure/clojure "1.10.3" :scope "provided"]
[org.xerial/sqlite-jdbc "3.36.0.3"]])
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ Treat SQLite as a JSON DB.
[![Build](https://github.com/daaku/sqjson-clj/workflows/build/badge.svg)](https://github.com/daaku/sqjson-clj/actions?query=workflow%3Abuild)

Documentation: https://cljdoc.org/d/org.clojars.daaku/sqjson

TODO:
- limit, order-by
- make opts work
5 changes: 3 additions & 2 deletions src/daaku/sqjson.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[jsonista.tagged :as jt]
[next.jdbc :as jdbc]
[next.jdbc.result-set :as rs])
(:import (clojure.lang Keyword PersistentHashSet)))
(:import [clojure.lang Keyword PersistentHashSet]
[daaku.ulid ULID]))

(def ^:private jdbc-opts {:builder-fn rs/as-arrays})

Expand Down Expand Up @@ -148,7 +149,7 @@
(defn- add-id [doc]
(if (contains? doc :id)
doc
(assoc doc :id (.toString (java.util.UUID/randomUUID)))))
(assoc doc :id (ULID/gen))))

(defmacro ^:private one-doc [ds params]
`(some-> (jdbc/execute-one! ~ds ~params jdbc-opts)
Expand Down

0 comments on commit b803777

Please sign in to comment.