Right syntax of Update


I have a document in Couchbase as structured below. I want to update the value for field body. Please help me with the right syntax.

Current doc

“body”: [

Future State - The below query shows sybtax error

UPDATE business_rules set body=’[“11”,“SAEDED”,“3P-U6-MO”]’ using keys [‘rule_external_rt_1’]

Thanks. Please help

UPDATE business_rules AS br USE KEYS ["rule_external_rt_1"]
SET br.body =  ARRAY_REPLACE(br.body, "WAKIRFALL", "SAEDED");




Thanks for the pointers. Is there any function to replace an array value based on position,. E.g.

I want to replace the value of 5th element of array as “xx”.


UPDATE business_rules AS br USE KEYS ["rule_external_rt_1"]
SET br.body[4] =  "xxx";

 UPDATE business_rules AS br USE KEYS ["rule_external_rt_1"]
 SET b.body = ARRAY  (CASE WHEN pos == 4 THEN "xx" ELSE v END) FOR pos:v IN body END

Thank you so much :slight_smile: