Update single values from one bucket to another

Hi, I am now facing a problem of updating a key from another bucket.

Suppose, my bucket1 has a document 123 with 3 key value pairs. I have to update the second key value with the value from bucket2 which has the same document.

So tried this out,

update bucket1 b
set value1 = (select value1 from bucket2 a use keys b.id)
where b.key1 is not missing;

Result was the value got copied to the value1 in bucket1 but as an array.

value1 :[ { value = “123343ewe2w” }].

But i want the update as directly,

value1 = “123343ewe2w”

What needs to be done? Please suggest.

try this

update bucket1 b
set value1 = (select  raw value1 from bucket2 a use keys b.id)[0]
where b.key1 is not missing;

should works.
maybe there is a better way.

This is not working.! Please suggest any other possible way?

what result do you get?
it should works. FYI

my test data:

INSERT INTO `test` (KEY, VALUE) VALUES ( "T:123",  {"type":"TTT","seq":1001,"value1":"123343ewe2w"}) RETURNING *;
INSERT INTO `default` (KEY, VALUE) VALUES ( "T:123",  {"type":"TTT","seq":1001,"value1":"123"}) RETURNING *;

this N1QL works

update default b
set value1 = (select raw value1 from test a use keys META(b).id )[0]
WHERE b.value1 is not missing returning *;
1 Like

Thanks. I missed the Keyword RAW.!