A newer version of this documentation is available.

View Latest

Updating documents

You can update a document by using the upsert() or replace() methods.

The replace() method replaces a document that already exists with new contents. The upsert() method creates the document if it does not already exist.

The following example shows how to update a document by using the replace() method:

$myBucket = $myCluster->openBucket();
$res = $myBucket->replace('document_name', array('some'=>'value'));

Sample output from the example:

object(CouchbaseMetaDoc)#4 (4) {
  resource(5) of type (CAS)