I would like to UPDATE a single document in a bucket with new values:
UPDATE bucket_name USE KEYS 'document_id' SET variable1 = new_value1
UPDATE bucket_name USE KEYS 'document_id' SET variable2 = new_value2
If variable1 and variable2 don’t exist in the document, then I want them to be added (UPDATE will fail if a variable does not exist).
I thought I could use UPSERT to resolve this, but from what I see, UPSERT will apply changes to ALL documents in a bucket, but I want to UPSERT to only a single document. How can I achieve this?
Awesome, that’s exactly what I was looking for. Thank you!
I ended up using this:
UPDATE bucket_name USE KEYS 'document_id' SET dictionary = CASE
WHEN `dictionary` IS MISSING THEN {} ELSE `dictionary` END,
dictionary.value = 'new_value'