使用 N1QL 从 couchbase 中的 json 获取嵌套对象
Get nested object from json in couchbase with N1QL
我在 Couchbase 中有以下条目 json:
{
"messageType": "TRANS",
"failCount": 0,
"workOrderDetailMap": {
"10873": {
"requestDate": "20160715151239",
"id": 10873,
"responseDate": "20160715151305",
"responseCode": 0,
"status": "SUCCESS",
"resultDocuments": [
"xyz"
]
}
}
}
我想通过 N1QL 查询获取 resultCode
字段:
Select * from myproject where workOrderDetailMap.responseCode = 0;
我得到了 0 个结果。
我该怎么做?
你需要
select * from myproject where workOrderDetailMap.`10873`.responseCode = 0;
如果需要忽略10873:
select * from myproject where object_values(workOrderDetailMap)[0].responseCode = 0;
我在 Couchbase 中有以下条目 json:
{
"messageType": "TRANS",
"failCount": 0,
"workOrderDetailMap": {
"10873": {
"requestDate": "20160715151239",
"id": 10873,
"responseDate": "20160715151305",
"responseCode": 0,
"status": "SUCCESS",
"resultDocuments": [
"xyz"
]
}
}
}
我想通过 N1QL 查询获取 resultCode
字段:
Select * from myproject where workOrderDetailMap.responseCode = 0;
我得到了 0 个结果。
我该怎么做?
你需要
select * from myproject where workOrderDetailMap.`10873`.responseCode = 0;
如果需要忽略10873:
select * from myproject where object_values(workOrderDetailMap)[0].responseCode = 0;