Quantcast
Channel: Mobile - Couchbase Forums
Viewing all articles
Browse latest Browse all 1124

Couchbase Lite Join multiple records

$
0
0

@AlexanderGreckov wrote:

Hi everyone! I I have the following documents:
Person

{
    "vehicle": {
        "couchId": "someid"
    }
}

OtherThing:

{
   "name": "thing one",
   "vehicle": {
     "couchId": "someid"
  }
}

{
  "name": "thing two",
  "vehicle": {
      "couchId": "someid"
  }
}

I need to get all person with other thing names. I used join for this purpose.

QueryBuilder
        .selectDistinct(
             SelectResult.expression(Expression.property("name").from("others"),
             ....
         )
         .from(datasource.as("persons"))
          .join(Join.leftJoin(datasource.as("others")).on(Expression.property("vehicle.couchId").from("persons").equalTo(Expression.property("vehicle.couchId").from("others"))

but when I am executing this query I’m receiving only one string, but I want to an get array like this ["thing one", "thing two"] for each matched person. How can I get this behaviour? How can I transform multiple matched items in my join to an array not to single item in the SelectResult?

I wanted to use group by and array_agg function for this, but couchbaselite for android doesn’t support array_agg((

Thanks in advance.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1124

Latest Images

Trending Articles



Latest Images