lib/pending-processor.js
function doCreate(datasetId, pendingChange, callback) {
  var record = pendingChange.post;
  var metaData = pendingChange.meta_data;
  debug('[%s] CREATE Start data = %j', datasetId, record);
  dataHandlers.doCreate(datasetId, record, metaData, function(err, data) {
    if (err) {
      debugError('[%s] CREATE Failed - : err = %s', datasetId, err);
    } else {
      debug('[%s] CREATE Success - uid = %s', datasetId, data.uid);
      pendingChange.oldUid = pendingChange.uid;
      pendingChange.uid = data.uid;
    }
    return saveUpdate(datasetId, pendingChange, err ? SYNC_UPDATE_TYPES.FAILED : SYNC_UPDATE_TYPES.APPLIED, err ? util.inspect(err) : null, callback);
  });
}
function doCreate(datasetId, pendingChange, callback) {
  var record = pendingChange.post;
  var metaData = pendingChange.meta_data;
  debug('[%s] CREATE Start data = %j', datasetId, record);
  dataHandlers.doCreate(datasetId, record, metaData, function(err, data) {
    if (err) {
      debugError('[%s] CREATE Failed - : err = %s', datasetId, err);
    } else {
      debug('[%s] CREATE Success - uid = %s', datasetId, data.uid);
      pendingChange.oldUid = pendingChange.uid;
      pendingChange.uid = data.uid;
    }
    return saveUpdate(datasetId, pendingChange, err ? SYNC_UPDATE_TYPES.FAILED : SYNC_UPDATE_TYPES.APPLIED, err ? util.inspect(err) : null, callback);
  });
}
function doCreate ( datasetId , pendingChange , callback ) { var record = pendingChange . post ; var metaData = pendingChange . meta_data ; debug ( '[%s] CREATE Start data = %j' , datasetId , record ) ; dataHandlers . doCreate ( datasetId , record , metaData , function ( err , data ) { if ( err ) { debugError ( '[%s] CREATE Failed - : err = %s' , datasetId , err ) ; } else { debug ( '[%s] CREATE Success - uid = %s' , datasetId , data . uid ) ; pendingChange . oldUid = pendingChange . uid ; pendingChange . uid = data . uid ; } return saveUpdate ( datasetId , pendingChange , err ? SYNC_UPDATE_TYPES . FAILED : SYNC_UPDATE_TYPES . APPLIED , err ? util . inspect ( err ) : null , callback ) ; } ) ; }
Create the given pending change in the backend.
It will always create the record in the backend.
@param {String} datasetId the dataset id
@param {Object} pendingChange the pending change. It should have the following fields
@param {String} pendingChange.datasetId the dataset id of the pending change
@param {Object} pendingChange.meta_data the meta_data of the dataset
@param {String} pendingChange.action the action of the pending change, should be "create"
@param {String} pendingChange.uid the unique id of the data record. This is a temp uid generated by the client and should be replaced by the real uid once the record is created.
@param {String} pendingChange.cuid the unique client id of the client device
@param {String} pendingChange.hash a unique id of the pending change, normally it is a hash value generated from the content of the pendingChange object
@param {Object} pendingChange.post the record after change
@param {Function} callback
Create the given pending change in the backend . It will always create the record in the backend .