Hi, My documents looks like this:
{"id":"P::R::1",type":"profile","name":"p1","status":"active"}
{"id":"P::R::2",type":"profile","name":"p2","status":"inactive"}
{"id":"R::1","type":"relationship","members":["user1"]}
{"id":"R::2","type":"relationship","members":["user1","user2"]}
{"id":"S::1","type":"subset","ref_key":"R::1","set":"set1"}
{"id":"S::2","type":"subset","ref_key":"R::1","set":"set2"}
{"id":"S::3","type":"subset","ref_key":"R::2","set":"set3"}
and all document are in bucket mydb
.
what I need :
1 get the result by members,such as where "user1" in members
;
2 join profile
document with relationship
document and join relationship `` document with ``subset` document. 2 group the result by key of
relationship```.
Following is what I want by where "user1" in members
condition:
[
{
"id": "R:1",
"name": "p1",
"status": "active",
"setlist": [
{
"id": "S::1",
"set": "set1"
},
{
"id": "S::2",
"set": "set2"
}
]
},
{
"id": "R:2",
"name": "p2",
"status": "inactive",
"setlist": [
{
"id": "S::3",
"set": "set3"
}
]
}
]
How should I write one N1QL to get the result?