rethinkdb / rethinkdb-java

Official RethinkDB Java client
https://rethinkdb.com/api/java/
Apache License 2.0
21 stars 10 forks source link

Implement r.pathspec(...) #16

Closed NotJustAnna closed 4 years ago

NotJustAnna commented 4 years ago

This issue is a continuation of https://github.com/rethinkdb/rethinkdb/issues/5007

Implement the discussed at the issue.

From the original issue:

Right now pathspecs are kind hairy due to Java's lack of nice hashmap and List literals:

in javascript:

r.table('foo').filter({x: {y: {z: "bar"}}})

turns into the java query:

r.table("foo").filter(r.hashMap("x", r.hashMap("y", r.hashMap("z", "bar"))))

Since depth-first is more common in path-specs than breadth first, it might make sense to have a special r.pathspec convenience that creates the appropriate hashmap structure. It might look something like:

r.table("foo").filter(r.pathspec("x", "y", "z", "bar"))

I haven't really thought about branching pathspecs too much, maybe there's no syntax that would work well. It's something to think about.

NotJustAnna commented 4 years ago

Implemented in develop/experimental (#7)

NotJustAnna commented 4 years ago

To be documented:

The best way to solve the breadth problem is pathspec with object:

r.table("foo").filter(
    r.object("x1", r.pathspec("y", "z", "bar"), "x2", r.pathspec("y", "z", "bar")
)