You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

batch()

Usage

batch(expression, batchSize)

Description
Enables batching for the given expression, i.e. if the expression contains a long-running function (for example the deletion of all nodes of a given type, see examples below), that function will be instructed to commit its results in batches of batchSize.

Useful in situations where large numbers of nodes are created, modified or deleted in a StructrScript expression.

Examples

${batch(delete(find('Item')), 1000)}
${batch(each(find('Item'), set(data, "visibleToPublicUsers", true)), 1000)}

Batching in server-side JavaScript
For examples how to use batching in server-side JavaScript scripts, see this article.

Search results for "batch()"

batch()

Enables batching for the given expression, i.e. if the expression contains a long-running function (for example the deletion of all nodes of a given type, see examples below), that function will be instructed to commit its results in batches of batchSize.
Useful in situations where large numbers of nodes are created, modified or deleted in a StructrScript expression.

In JavaScript the batch() function takes a worker function as its first parameter and an optional error handler function as its second parameter. If the worker function returns true, it is run again. If it returns anything else it is not run again. If an exception occurs in the worker function, the error handler function (if present) is called. If the error handler returns true, the worker function is called again. If the error handler function returns anything else (or an exception occurs) the worker function is not run again.

batch(expression, batchSize)

// DEPRECATED in JavaScript!
$.batch(workerFunction [, errorHandlerFunction ] )