0
votes

I have scenario to insert a new attribute in couchbase document.

For ex : I have a document like: { "x" : "value1", "y" : "value2" }

I just want to insert another key "z", for which value should be taken from key "y".

My expected result should be like: { "x" : "value1", "y" : "value2", "z" : "value2" }

Note : "x" is unique id.

Kindly suggest me couchbase N1QL query for better performance.

1
Can you let us know what you have already tried and clarify what you mean by "better performance"? - Jerod Johnson

1 Answers

0
votes

If you need to update all documents

UPDATE default SET z = y;

If you need to update based on condition.

UPDATE default SET z = y WHERE x = "value1";