N1QL Query: Select data based on multiple keys

Hi,

I have two documents

Document 1 (meta Id: A) :

{
   "id":"A",
   "type": "t1",
   "arr":[
             { 
               "v":"1"
             }
          ]
}

Document 2 (meta Id: B) :

{
   "id":"B",
   "type": "t2",
   "arr":[
             { 
               "v":"2"
             }
          ]
}

I need a n1ql query that will return type and arr from B if document B exists otherwise it will return those from document A.

How can I create the n1ql for that?

Thanks,
Himanshu

WITH B AS ((SELECT RAW b FROM mybucket AS b USE KEYS "B")[0]),        
     A AS ((SELECT RAW a FROM mybucket AS a USE KEYS "A")[0])
SELECT RAW IFMISSING(B,A);

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.