{
"name":"nick",
"emailId":"nick123@gmail.com",
"subjects" : [{
"name":"SOA",
"tutor":"roshan",
"classes" : "12"
},
{
"name":"UNIX",
"tutor":"mathew",
"classes" : "9"
}
],
"id" : "12345"
}
我想使用更新查询添加另一组主题。
我厌倦了看一些网站,但它显示错误,我无法理解。
如果您给出建议并感谢您的帮助,将会更有帮助。
我累的查询是: -
[更新studapp
ARRAY a.name =“networks”,a.tutor =“shalin”,a.classes =“8”
对于IN科目END
其中id ='12345';]
答案 0 :(得分:2)
update `studapp`
SET subjects= ARRAY_APPEND( subjects, { "name":"SE",
"tutor":"Mani",
"classes" : "7" } )
where id = '12345';
我得到了我需要的结果(为现有数组添加了一组新值)
<强> RESULT 强>
{
"name":"nick",
"emailId":"nick123@gmail.com",
"subjects" : [{
"name":"SOA",
"tutor":"roshan",
"classes" : "12"
},
{
"name":"UNIX",
"tutor":"mathew",
"classes" : "9"
}
{
"name":"SE",
"tutor":"Mani",
"classes" : "7"
}
],
"id" : "12345"
}
答案 1 :(得分:0)
见
n1ql query to remove data from array which has parameter value null
https://dzone.com/articles/couchbase-n1ql-continuing-to-simplify-transition-f
https://forums.couchbase.com/t/update-value-in-an-array-of-strings-within-an-array/9797
n1ql query to update multiple parameters in array of json data
Update specific object in the array of object in couchbase 4.1