Skip to content

Instantly share code, notes, and snippets.

@ccfontes
ccfontes / change-datomic-schema-fulltex-idx.clj
Last active January 16, 2024 12:06
Change datomic schema by adding a fulltext index to :url/path attribute
; 1. rename attribute: :url/path → :legacy/url-path-v1
(do (require '[datomic.api :as datomic] '[kanasubs.db :as db])
(datomic/transact @db/connection
[{:db/id :url/path, :db/ident :legacy/url-path-v1}]))
; 2. repurpose :url/path
(do (in-ns 'kanasubs.db)
(transact @connection
[{:db/id #db/id[:db.part/db]
:db/ident :url/path
@vvvvalvalval
vvvvalvalval / aynchronous-errors.clj
Last active February 27, 2024 15:49
Asynchronous error management in Clojure(Script)
;; Synchronous Clojure trained us to use Exceptions, while asynchronous JavaScript has trained us to use Promises.
;; In contexts where we work asynchronously in Clojure (in particular ClojureScript), it can be difficult to see a definite way of managing failure. Here are some proposals.
;; OPTION 1: adapting exception handling to core.async CSPs
;; As proposed by David Nolen, with some macro sugar we use Exceptions in go blocks with core async in the same way we would do with synchronous code.
(require '[clojure.core.async :as a :refer [go]])
;; defining some helper macros
(defn throw-err "Throw if is error, will be different in ClojureScript"