Couchbase查询子文档中的数字属性名称

时间:2017-01-09 14:40:11

标签: properties couchbase n1ql

我的文档看起来像:

{
  "mobile": {
    "default": {
      "s": {
        "camp": {
          "100112": 0,
          "100114": 0,
          "100122": 0
        },
        "score": 1
      }
    }
  }
}

我想选择一个标准的文档,如:

select * from my_bucket where mobile.default.s.camp.100112 = 0

但是我遇到了语法错误:

[
  {
    "code": 3000,
    "msg": "syntax error - at 100112",
    "query_from_user": "select  * from `user_scoring_sample` t where mobile.default.s.camp.100112 = 0"
  }
]

是否允许拥有数字属性名称?我们必须在n1ql查询中转义它们吗?

1 个答案:

答案 0 :(得分:2)

您可以使用反引号字符`转义关键字,包含特殊字符的表/属性和数字表/属性。

例如:

SELECT * FROM my_bucket where mobile.default.s.camp.`100112` = 0
相关问题