2017-03-03 76 views
0

這可能更像是一個普遍的查詢問題,因爲我對數據庫相當陌生。N1ql Couchbase:如何讓N1qlQueryResult獲得子項?

如果我有一個couchbase桶這個文件:

{ 
    "accId": "1234", 
    "operation": "test", 
    "response": "a response" 
} 

我能得到的代碼響應

N1qlQueryResult result = bucket.query(select("response").fromCurrentBucket().where((x("accId").eq("\""+Id+"\"")).and(x("operation").eq("\""+op+"\"")))); 

但如果我的JSON是這樣的:

{ 
    "organization": { 
    "accId": "1234", 
    "operation": "test", 
    "response": "a response 
    } 
} 

我將如何着手獲得迴應?

感謝您的幫助。

回答

2

Couchbase存儲JSON文檔。所以它會像下面提到的查詢那樣被提取。

select * from bucketName where organization.accId="1234" and organization.operation="test"