I have a document whose DocumentId is a random number (UUID), need to update & fetch a unique record with specific status value (say NEW to INPROGRESS) with limit 1
Does Couchbase guarantee to update and retrieve one and only one unique record (for concurrent requests)?
UPDATE bucket SET status = ‘INPROGRESS’ where status = ‘NEW’ limit 1 RETURNING *
Return document key
UPDATE bucket SET status = ‘INPROGRESS’ where status = ‘NEW’ limit 1 RETURNING META().id;
Returns document and document key
UPDATE bucket AS d SET d.status = ‘INPROGRESS’ where d.status = ‘NEW’ limit 1 RETURNING d, META().id;
UPDATE requires fetch the document, as part of fetch it also gets CAS value and same CAS value is passed it back while updating document. If the values are different the update will raise error. cc @keshav_m