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:

var myBucket = myCluster.openBucket();
myBucket.insert('document_name', {some:'value'}, function(err, res) {
  if (err) {
    console.log('operation failed', err);
    return;
  }

  console.log('success!', res);
});

Sample output from the example:

success! { cas: { '0': 1927806976, '1': 2727156638 } }