简体   繁体   中英

N1ql Couchbase: How to get child with N1qlQueryResult?

This might be more of a general querying question as I'm fairly new to databases.

If I have this document in a couchbase bucket:

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

I can get the response with the code

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

But if my JSON looks like this:

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

How would I go about getting the response?

Thanks for the help.

Couchbase stores JSON document. So it will be fetched as mentioned as below mentioned query.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM