JSON AST to RethinkDB query