I have in my bucket a document containing a list of ID (childList). I would like to query over this list and keep the result ordered like in my JSON. My query is like (using java SDK) :
String query = new StringBuilder().append("SELECT B.name, META(B).id as id ")
.append("FROM
" + bucket.name() + "A ")
.append("USE KEYS $id ")
.append("JOIN
" + bucket.name() + "B ON KEYS ARRAY i FOR i IN A.childList end;").toString();
This query will return rows that I will transform into my domain object and create a list like this :
n1qlQueryResult.allRows().forEach(n1qlQueryRow -> (add to return list ) ...);
The problem is the output order is important.
Any ideas?
Thank you.
here is a rough idea of a solution without N1QL, provided you always start from a single A document:
You might want another
map
before thetoList
to extract the name and id, or to perform your domain object transformation even maybe...The steps are:
List<JsonDocument>