N1QL选择仅数字键

时间:2019-07-12 06:53:40

标签: couchbase n1ql

我有一个类似文件

{
    "bucket_name": {
      "0": 2,
      "1": 107,
      "2": 61,
      "3": 428,
      "username": "tester2",
      "obj_type": 21,
      "date": 1562416800
    }
}

我该如何选择仅数字的json键,我尝试了类似的方法:

select 0 from bucket_name where obj_type=21 and username='tester'

但它返回:

[
    {
      "$1": 0,
    },
    {
      "$1": 0,
    },
    {
      "$1": 0,
    },
]

1 个答案:

答案 0 :(得分:0)

使用反引号(即转义标识符)https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/identifiers.html

SELECT `0` 
FROM bucket_name
WHERE obj_type=21 AND username='tester';