当具有这样的嵌套文档时:
{
"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"
}
]
}
网站说明:以下语句将在“收藏博客”的根文档中添加一个字段:
UPDATE Blog SET rank = "top blog" WHERE blog = "testblog1";
是的,您可以在N1QL中执行以下操作:
更新博客集
c.ranking =“最高评论” FOR c IN评论,当c.comment =“ testcomment2”结束时
blog =“ testblog1”
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句