我是 Couchbase 的新手,我得到了这个结构:
{
items: [
{
id: "a1",
subitems: [
{
id: "b1",
name: "joe1"
},
{
id: "b2",
name: "joe2"
}
]
}
],
docType: "mydoc"
}
我需要为子项内的每个对象添加新字段。我知道如何使用 1 级数组执行此操作 =>
UPDATE default SET a.newField='blabla' FOR a IN items END where docType = 'mydoc';
它将产生:
{
items: [
{
newField: "blabla",
id: "a1",
subitems: [
{
id: "b1",
name: "joe1"
},
{
id: "b2",
name: "joe2"
}
]
}
],
docType: "mydoc"
}
但我需要这个结果:
{
items: [
{
id: "a1",
subitems: [
{
newField: "blabla",
id: "b1",
name: "joe1"
},
{
newField: "blabla",
id: "b2",
name: "joe2"
}
]
}
],
docType: "mydoc"
}
谢谢你的帮助。