Skip to content

podviaznikov/clj-rethinkdb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-rethinkdb

A RethinkDB client for Clojure. Tested with 1.15.x but should with work all versions that support the JSON protocol (i.e. >= 1.13).

Circle CI

Install

Clojars Project

Usage

(require '[rethinkdb.core :refer [connect close]])
(require '[rethinkdb.query :as r])

(let [conn (connect :host "127.0.0.1" :port 28015)]
  (r/run (r/db-create "test") conn)
  (-> (r/db "test")
      (r/table-create "authors")
      (r/run conn))
  (-> (r/db "test")
      (r/table "authors")
      (r/index-create "genre" (r/fn [row]
                                (r/get-field row :genre)))
      (r/run conn))
  (-> (r/db "test")
      (r/table "authors")
      (r/insert [{:name "E.L. Jamas"
                  :genre "crap"
                  :books ["Fifty Shades of Grey"
                          "Fifty Shades Darker"
                          "Fifty Shades Freed"]}
                 {:name "Stephenie Meyer"
                  :genre "crap"
                  :books ["Twilight" "New Moon" "Eclipse" "Breaking Dawn"]}])
      (r/run conn))
  (-> (r/db "test")
      (r/table "authors")
      (r/get-all ["crap"] {:index "genre"})
      (r/filter (r/fn [row]
                  (r/eq "Stephenie Meyer" (r/get-field row "name"))))
      (r/run conn))
  (close conn))

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%