Following is the sample document ( userdetails) in couchbase.
{
\"friends\": [
{
\"company\": \"microsoft\",
\"firstname\": \"criss\",
\"lastna
Each SET term is independent, so you can do the following:
UPDATE default
USE KEYS "userdetails"
SET a.firstname="abc" FOR a IN friends WHEN a.company="microsoft" END,
a.lastname="xyz" FOR a IN friends WHEN a.company="microsoft" END
RETURNING friends;
To answer your comment, the following two forms avoid the double loop. You can measure with actual data to see which form gives the best performance.
UPDATE default
USE KEYS "userdetails"
SET friends[i] = {"firstname":"abc", "lastname":"xyz", "company":"microsoft"} FOR i : a IN friends WHEN a.company="microsoft" END
RETURNING friends;
UPDATE default
USE KEYS "userdetails"
SET friends[i] = OBJECT_PUT(OBJECT_PUT(a, "firstname", "abc"), "lastname", "xyz") FOR i : a IN friends WHEN a.company="microsoft" END
RETURNING friends;