Creating documents

You can create a document by using the insert() or upsert() methods.

Performing an insert succeeds only if no document with that name exists. In contrast, an upsert overwrites any existing matching document.

The following example shows how to create a new document with the insert() method:

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

Sample output from the example:

object(CouchbaseMetaDoc)#4 (4) {
  ["cas"]=>
  resource(5) of type (CAS)
}