Batch Operations (App)
Version compatibility
This feature was introduced in version 4.20 of the JourneyApps Container.
JourneyApps includes a way for the app to batch together many save or destroy operations to significantly increase the performance of a function. Instead of using one network request per operation, it batches all of them into a single network request.
Example usage:
Methods
Name | Usage |
---|---|
| Adds an item to be saved. Equivalent to |
| Adds an item to be destroyed. Equivalent to |
| Executes the batch |
Large batches
If the batch contains more than 1000 operations, it will internally be split into separate smaller network requests.
Error handling
The execute()
function can throw an Error, typically in these scenarios:
A network error occurred. This could be before or after the server received and processed the batch.
An attempt is made to update (save) an object that has been deleted elsewhere.
There is a data-model mismatch
It is safe to attempt recovery from these errors by performing batch.execute()
again. Any objects that have been confirmed as saved (e.g. the first part of a large batch) will not be saved again. Duplicate objects will not be created, since the IDs for new objects are generated on the device (not on the server).
Note that error types (2) and (3) above are generally not recoverable by retrying the same batch.
Last updated