Want to add 2 more users in both the group. But it is but working as excepted.
couchbase version --4.6.2-3095 enterprise edition
sql— UPDATE app SET lg1.users = ARRAY_APPEND(lg1.users,$1)
FOR lg1 in pg.lg
FOR pg1 in pg
WHEN pg1.name = $2 AND lg1.name = $3
END
WHERE META(app).id = $4`
Want to add 2 more users in both the group. But it is but working as excepted.
couchbase version --4.6.2-3095 enterprise edition
sql— UPDATE app SET localUserGroup.users = ARRAY_APPEND(localUserGroup.users,$1)
FOR localUserGroup in policyGroup.localUserGroups
FOR policyGroup in policyGroups
WHEN policyGroup.name = $2 AND localUserGroup.name = $3
END
WHERE META(app).id = $4`
Qualifies only one localUseGroup , you have different names.
If need to add new users for all the user usergroups change to WHEN policyGroup.name = $2 END or make it OR/IN on both names (WHEN policyGroup.name = $2 AND localUserGroup.name IN $3 END, supply $3 as [“localGroup1”, “localGroup2”])
What are the query parameter values and what is expected updated document and what actually happening.
UPDATE app SET lg1.users = ARRAY_APPEND(lg1.users,$1)
FOR lg1 in pg1.lg
FOR pg1 in pg
WHEN pg1.name = ‘pgroup1’ AND lg1.name = 'localGroup1’
END
WHERE META(app).id = ‘appid’`
loop2—
UPDATE app SET lg1.users = ARRAY_APPEND(lg1.users,$1)
FOR lg1 in pg1.lg
FOR pg1 in pg
WHEN pg1.name = ‘pgroup1’ AND lg1.name = 'localGroup2’
END
WHERE META(app).id = ‘appid’`
I have provided how to do through single update in my previous post. Are you still have issue.
UPDATE app USE KEYS ["appid"]
SET lg1.users = ARRAY_APPEND(lg1.users,$1)
FOR lg1 IN pg1.lg
FOR pg1 IN pg
WHEN pg1.name = "pgroup1" AND lg1.name IN ["localGroup1", "localGroup2"] END;