I have tables of the following kind
entity
|id|title|
entity_authors
|id|authorName|
entity_to_authors
|id|entityId|authorId|
I managed to join the tables entity
and entity_to_authors
r.table("entity")
.get("f17234b6-b25c-4037-8dd1-314841967964")
.merge({e -> r.hashMap("entity_to_authors", r.table("entity_to_authors").filter(r.hashMap("entityId", e.g("id"))).coerceTo("array"))})
.run<Unit>(connection)
Now I need to get data from the table entity_authors
I did it this way (but it's wrong)
r.table("entity")
.get("f17234b6-b25c-4037-8dd1-314841967964")
.merge({e -> r.hashMap("entity_to_authors", r.table("entity_to_authors").filter(r.hashMap("entityId", e.g("id"))).coerceTo("array"))})
.merge({e -> r.hashMap("entity_authors", r.table("entity_authors").filter(r.hashMap("id", e.g("entity_to_authors").nth(0).g("authorId"))).coerceTo("array"))})
.run<Unit>(connection)
since here I use nth(0)
to get the first line of data received from entity_to_authors
What should I do to get all the authors?
Sorry for my English!