正在更新n1q1查询CB中的子文档映射



这是我在CB、中的文档

{
"users": {
"11111": "ACTIVE",
"22222": "ACTIVE",
"33333": "ACTIVE",
"44444": "ACTIVE",
"55555": "ACTIVE",
"666666": "ACTIVE",
"777777": "ACTIVE",
"888888": "ACTIVE"
}
}

我想将此用户映射的所有密钥更新为0,而不是活动密钥。

预期输出

{
"users": {
"11111": 0,
"22222": 0,
"33333": 0,
"44444": 0,
"55555": 0,
"666666": 0,
"777777": 0,
"888888": 0
}
}

我试过这个

更新bucketname.users中的bucketname SET x=0 FOR xmeta((.id='%documentKey%'

UPDATE mybucket AS b
SET b.users = OBJECT n:0 FOR n:v IN b.users END
WHERE ......

构建新对象并设置值

FOR n:v IN b.users END
iterates each field of b.users (n holds name, v holds value)
OBJECT n:0  
Construct new object field name from n and value is 0 constant

最新更新