hamiltop / rethinkdb-elixir

Rethinkdb client in pure elixir (JSON protocol)
MIT License
497 stars 64 forks source link

Add support for human-readable queries #120

Closed almightycouch closed 7 years ago

almightycouch commented 7 years ago

This is something I missed for really long time 😜.

Basically, it implements the Inspect protocol for RethinkDB.Q. It also transform references (within lambdas) to variable names (a, b, c, etc.).

Only downside is that we have an external JSON resource. The file has been taken from the official Java driver and shrinked down to contain only the the necessary ReQL id => name mappings.

import RethinkDB.{Query, Lambda}

table("people")
|> filter(lambda &(&1["age"] >= 21))
|> IO.inspect

Prints

filter(table("people"), fn(a, ge(bracket(var(a), "age"), 21)))
hamiltop commented 7 years ago

Awesome.