clj-rethinkdb
clj-rethinkdb copied to clipboard
Auto generating query code
The RethinkDB Java driver auto generates it's code from an advanced JSON spec of the RethinkDB query language. It should be possible to auto generate this code in Clojure too using macros.
Pros:
- Easily stay up to date with the official releases
- Always fully compliant with the latest ReQL spec
Cons:
- Macro code may be complex
- We may lose code completion using macros
- Not sure how we get docstrings with this approach.
This is very interesting and would be great to be able to compose the query using only data (maps?) or data + macro.
You can already do this :) Run (r/db :mydb) and look at the output. Then run (-> (r/db :mydb) (r/table :mytable)). The query is built up as data, then converted into the JSON protobuf message that RethinkDB needs when you run it.
Ah cool, but I was more thinking of doing it on the frontend (see other issue), rethinkdb queries look indeed very composable..