apa512 / clj-rethinkdb

Eclipse Public License 1.0
205 stars 42 forks source link

add r/expr term #178

Closed nha closed 7 years ago

nha commented 7 years ago

The expr query is missing: https://www.rethinkdb.com/api/javascript/expr/

My use case: it seems necessary for a workaround to create tables atomically:

(defn ensure-db
  "atomic ensure-db"
  [db]
  (r/branch (r/contains (r/db-list) db)
            (r/expr {:config_changes [] :dbs_created 0})
            (r/db-create db)))
apa512 commented 7 years ago

Are you getting any errors?

I just tried

(r/run (r/branch (r/contains (r/db-list) "rethinkdb") {:config_changes [] :dbs_created 0} (r/db-create "rethinkdb")) conn)

and that worked fine, returning a normal Clojure map when the DB exists.

danielcompton commented 7 years ago

I don't think expr is needed in Clojure as we have syntax for data literals already?

nha commented 7 years ago

Ah right then sorry for the noise - closing this issue.