clj-rethinkdb icon indicating copy to clipboard operation
clj-rethinkdb copied to clipboard

Auto generating query code

Open danielcompton opened this issue 10 years ago • 3 comments
trafficstars

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.

danielcompton avatar Nov 15 '15 22:11 danielcompton

This is very interesting and would be great to be able to compose the query using only data (maps?) or data + macro.

arichiardi avatar Jul 04 '16 01:07 arichiardi

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.

danielcompton avatar Jul 04 '16 07:07 danielcompton

Ah cool, but I was more thinking of doing it on the frontend (see other issue), rethinkdb queries look indeed very composable..

arichiardi avatar Jul 04 '16 16:07 arichiardi