当有这样的嵌套文档时:
{
"blog": "testblog1",
"user_id": 41,
"comments": [
{
"comment": "testcomment1",
"user_id": 883
},
{
"comment": "testcomment2",
"user_id": 790
}
]
}
可以使用 N1QL 进行更新操作以向子文档添加额外字段吗?
我想将该字段添加"ranking" : "top comment"
到带有注释 testcomment2 的子文档中:
{
"blog": "testblog1",
"user_id": 41,
"comments": [
{
"comment": "testcomment1",
"user_id": 883
},
{
"comment": "testcomment2",
"user_id": 790,
"ranking" : "top comment"
}
]
}
站点注释:以下语句将在 Collection Blog 的根文档中添加一个字段:
UPDATE Blog SET rank = "top blog" WHERE blog = "testblog1";