Is there a Clojure in the data store in memory?

I program mainly in Node and as document repositories, but first I want to prototype data calls between the client and server. I have used lowdb and da-base in the past to set up fast Json data storage. Is there something similar for Clojure?

+4
source share
2 answers

Given that you're just a prototype, if you don't need strength, a simple atom will do. If you want durability using simple files look at https://github.com/alandipert/enduro

You can have one atom at a table or you can have an atom with a table-> docs map, no matter what you find easier. Any request will be just a filter.

For example, to add a document:

(def my-db (atom {}))
(defn add [table doc] (swap! my-db update-in [table] conj doc))
(defn search-by-name [table name] 
    (filter #(= name (:name %)) (get @my-db table)))
+5
source

Datascript seems to be ideal (albeit poorly named), suitable for your needs. This is essentially a lightweight memory store created after Datomic. Using the card-in-atom approach, you will very quickly find that you are writing unusual code for selection, identity management, etc. Datascript takes care of such things and makes it easy to write complex queries, while still being almost as light as a card in an atom.

+3
source

All Articles