How to n1ql update join

n1ql

#1

exmaple code
hi.
I do not understand English well and use translator
excode)
UPDATE user u INNER JOIN game g
ON KEYS meta(u).id || "_prefix"
SET u.test_v = u.test_v + g.run_upgrade_material[0]

I want to match the user key to the game key and join update query

how to make query?


#2

You cannot use JOIN with UPDATE. JOIN only works with SELECT.


#3

thank you very much ^^


#4

UPSERT SELECT should work for this case:

UPSERT INTO user x (key _k, value new_v)
SELECT
meta(u).id AS _k,
u AS _v,
OBJECT_PUT(u, “test_v”, u.test_v + g.run_upgrade_material[0]) AS new_v
FROM user u
INNER JOIN game g ON KEYS meta(u).id || “_prefix”
returning meta(x).id, x