Skip to content

Instantly share code, notes, and snippets.

@jensarps
Created February 27, 2013 09:59
Show Gist options
  • Save jensarps/5046786 to your computer and use it in GitHub Desktop.
Save jensarps/5046786 to your computer and use it in GitHub Desktop.
A putAll / putMany convenience method for IDBWrapper
/**
* Takes an array of data objects to store and calls IDBWrapper's batch() method
*
* @param {Array} dataArray An array of objects to be stored
* @param {Function} [onSuccess] Gets called if the operation was successful
* @param {onError} [onError] Gets called if an error occurred
*/
function putMany (dataArray, onSuccess, onError) {
var preparedData = dataArray.map(function(dataObject){
return {
type: 'put',
value: dataObject
};
});
myIDBStoreInstance.batch(preparedData, onSuccess, onError);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment