Created
December 29, 2016 08:12
-
-
Save dvcrn/e040c0067a7fa8adf44b174de1e837cd to your computer and use it in GitHub Desktop.
realm example in clojurescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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