【问题标题】:N1ql Couchbase: How to get child with N1qlQueryResult?N1ql Couchbase:如何使用 N1qlQueryResult 获取孩子?
【发布时间】:2017-03-03 23:33:21
【问题描述】:

这可能是一个更一般的查询问题,因为我对数据库还很陌生。

如果我有这个文件在沙发桶里:

{
  "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
  }
}

我将如何获得响应?

感谢您的帮助。

【问题讨论】:

    标签: java couchbase nosql


    【解决方案1】:

    Couchbase 存储 JSON 文档。因此,它将按照下面提到的查询进行获取。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多