I have this n1ql query:
UPDATE default
USE KEYS '557a7628-1217-4974-95cf-d64247c560cd'
SET p.last_seen_message_id = 'e5010536-7fde-42c1-9fea-e4a29e560f53'
FOR p IN participants WHEN p.id = '119c35ab-a1cc-4e9f-bab5-d58d6d396623' END
WHERE doc_type = 'conversation'
RETURNING default.*
The documents have the following structure:
"default": {
"doc_created_at": "2016-09-26T05:59:03.288Z",
"doc_created_by": "119c35ab-a1cc-4e9f-bab5-d58d6d396623",
"doc_id": "557a7628-1217-4974-95cf-d64247c560cd",
"doc_patched_at": "2016-11-09T14:01:00.098Z",
"doc_type": "conversation",
"last_message_id": "e998a087-c0d1-4f62-9e0d-86899e408e40",
"last_message_text": "19",
"participants": [
{
"id": "6e1a1ab9-1082-4250-bcb1-773df70fd206",
"last_seen_message_id": "unknown",
"name": "User 2"
},
{
"id": "119c35ab-a1cc-4e9f-bab5-d58d6d396623",
"last_seen_message_id": "unknown",
"name": "User 1"
}
],
"sender": {
"id": "119c35ab-a1cc-4e9f-bab5-d58d6d396623",
"name": "User 1"
},
"text": "19"
}
The update works (the document is updated correctly) but the result is an empty array. I tried this query using the Couchbase Console Query editor and there I get the result back.
I use Couchbase 4.5.1-2845 on Windows, Node.js version 6.5.0, and the couchbase 2.2.2 module (from npm).