Update


With UPDATE statement Clusterpoint can update a particular document.

The Update command rewrites mentioned fields or adds new field (if such does not exist) in existing document, or if a document with the specified ID does not exist, the Update command returns an error.

UPDATE product["34940855"] SET availability = "OutOfStock"
UPDATE product["34940855"] SET packaging.height = 11, packaging.width = 12

In SET clause of UPDATE statement arbitrary JavaScript code can be run. You can view this as document being deserialized as a JavaScript object and method executed on it, which can modify state of the object arbitrarily. In the following example we can use UPDATE and simple JavaScript to create a new field and calculate its value from the data we have in the document - all within a single database request.

UPDATE product["34940855"] SET packaging.volume = packaging.height * packaging.width * packaging.depth