Skip to content

Instantly share code, notes, and snippets.

@dvcrn
Created December 29, 2016 08:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvcrn/e040c0067a7fa8adf44b174de1e837cd to your computer and use it in GitHub Desktop.
Save dvcrn/e040c0067a7fa8adf44b174de1e837cd to your computer and use it in GitHub Desktop.
realm example in clojurescript
(def Realm (js/require "realm"))
;; define dog schema
(def dog {:name "Dog"
:properties {:name "string"
:age "int"}})
;; instantiate Realm with the dog schema
(def r (Realm. (clj->js {:schema [dog]})))
;; create a new puppy
(.write r (fn []
(.create r "Dog" (clj->js {:name "Rex" :age 3}))))
;; get all dogs
(let [all-dogs (.objects r "Dog")]
(println all-dogs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment