Enables executing a batch of writeItem
,
writeBinaryItem
, deleteItemWithAction
,
addActionWithItemReference
, addAction
,
getItems
and runQuery
calls to the Client
Store API on the local storage.
Until announced otherwise, the writeBinaryItem
,
deleteItemWithAction
and
addActionWithItemReference
methods are not supported on
Android.
Name | Description | Type | Use |
---|---|---|---|
onCollectQueries | A callback function, which allows to define queries as part of the
batch parameter. It passes an object that defines functions,
whose signatures match those given in the writeItem, writeBinaryItem, deleteItemWithAction, addActionWithItemReference, addAction, getItems, and runQuery articles. |
function |
required |
onSuccess | A callback function, which passes a |
function |
optional |
onFailure | A callback function, called if any of the queries forming the batch fails. It passes an error code, as defined in the Constants table in the Client Store article, and an error message. | function |
optional |
The onCollectQueries
callback can be implemented as
follows:
function(batch) { batch.writeItem("type of item 1", "handle of item 1", "data of item 1"); batch.writeBinaryItem("type of item 2", "handle of item 2", "file reference of item 2"); batch.getItems("type of item 3", "handle of item 3"); batch.addAction ("metadata of action", "data of action", "options of action"); ... }
The runQuery
call cannot exist in a single batch with any of
the following calls: writeItem
,
writeBinaryItem
,
addActionWithItemReference
, and
deleteItemWithAction
.
As its call parameter, the onSuccess
callback returns an array of
objects passed to the onSuccess
callback of their respective
functions. For the writeItem
,
writeBinaryItem
, and deleteItemWithAction
methods, the object is null, which denotes that no parameter is passed.