lib/db.js
function _errorCb(err, result) {

          // if there is a conflict error, retrieve the document's revision first
          function _successCb(err, result) {

            // use the revision to update the existing documents
            // NOTE: it is not impossible that the revision of this document
            // is modified by other operations right before updating, Couchpenter
            // will only try once to avoid any possibility of retrying infinitely.
            doc._rev = result._rev;
            self.couch.use(dbName).insert(doc, self._handle(cb, {
              dbName: dbName,
              docId: doc._id,
              message: 'updated'
            }));
          }

          self.couch.use(dbName).get(doc._id, self._handle(cb, {
            dbName: dbName,
            docId: doc._id,
            successCb: _successCb
          }));
        }
function _errorCb(err, result) {

          // if there is a conflict error, retrieve the document's revision first
          function _successCb(err, result) {

            // use the revision to update the existing documents
            // NOTE: it is not impossible that the revision of this document
            // is modified by other operations right before updating, Couchpenter
            // will only try once to avoid any possibility of retrying infinitely.
            doc._rev = result._rev;
            self.couch.use(dbName).insert(doc, self._handle(cb, {
              dbName: dbName,
              docId: doc._id,
              message: 'updated'
            }));
          }

          self.couch.use(dbName).get(doc._id, self._handle(cb, {
            dbName: dbName,
            docId: doc._id,
            successCb: _successCb
          }));
        }
function _errorCb ( err , result ) { // if there is a conflict error, retrieve the document's revision first function _successCb ( err , result ) { // use the revision to update the existing documents // NOTE: it is not impossible that the revision of this document // is modified by other operations right before updating, Couchpenter // will only try once to avoid any possibility of retrying infinitely. doc . _rev = result . _rev ; self . couch . use ( dbName ) . insert ( doc , self . _handle ( cb , { dbName : dbName , docId : doc . _id , message : 'updated' } ) ) ; } self . couch . use ( dbName ) . get ( doc . _id , self . _handle ( cb , { dbName : dbName , docId : doc . _id , successCb : _successCb } ) ) ; }
try to create documents, but with conflict error handling
try to create documents but with conflict error handling