Created
February 27, 2013 09:59
-
-
Save jensarps/5046786 to your computer and use it in GitHub Desktop.
A putAll / putMany convenience method for IDBWrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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