Pico ORM, when simple data require simple data management.
(ns example
(:require
[cellar.core :as db]
[cellar.config :as cfg]))
;; providing db settings
(cfg/-db-settings>
{:classname "org.h2.Driver"
:subprotocol "h2:mem"
:subname "demo;DB_CLOSE_DELAY=-1"
:user "sa"
:password ""})
;; creating a new table
(db/deftable cellar-shelves
:conditional!
[[:id "BIGINT"]
[:shelve-height "BIGINT"]
[:shelve-content "VARCHAR(64)"]])
;; OR
(db/deftable cellar-shelves
:conditional!
{:id "BIGINT"
:shelve-height "BIGINT"
:shelve-content "VARCHAR(64)"})
;; OR
(db/deftable cellar-shelves
:conditional!
{:id :bigint
:shelve-height :bigint
:shelve-content :varchar64})
;; inserting new record
(db/insert! :cellar-shelves
{:id 1
:shelve-height 2
:shelve-content "One small lib"})
;; => {:id 1 :shelve-height 2 :shelve-content "One small lib"}
;; let's check if new record exists
(db/exists? :cellar-shelves {:id 1})
;; => true ; indeed, it was just created
(db/update! :cellar-shelves
{:shelve-height 3}
{:id 1})
;; => 1 ; only one record was updated
(db/delete! :cellar-shelves
{:id 1})
;; => 1 ; only one record was deleted
There are plenty of ORM's out there, but mostly they are much larger. For small, close to pet-projects, it is overkill to use anything larger, than this ORM.
Mainly it is designed and created for my private pet-projects.
-foo>
and <foo-
Code notations of this project:
-foo>
- alias for set foo
<foo-
- alias for get foo
-foo
- private functionfoo!
- state altering functionfoo!!
- heavy state altering functionCan you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close