SDK
SDK Javascript v7.x
2

mexecute #

Allows the execution of multiple commands or 'actions' in a single step.

It creates a Redis transaction block and executes it immediately, all actions will be executed sequentially and as a single atomic and isolated operation.

[Redis documentation]

Only already valid actions of the memoryStorage controller can be executed using mexecute.

Arguments #

Copied to clipboard!
mexecute(actions, [options]);

Arguments Type Description
actions
object[]
List of actions to execute
options
object
Optional query arguments

actions #

The actions argument is an array of objects. Each object describes an action to be executed, using the following properties:

Property Type Description
action
string
Action name
args
object
Arguments

Resolve #

Returns an array of error & result pairs for each executed action, in order.

Usage #

Copied to clipboard!
try {
  const actions = [
    { 'action': 'set', 'args': { '_id': 'list:a', 'body': { 'value': 1, 'ex': 100, 'nx': true } } },
    { 'action': 'get', 'args': { '_id': 'list:a' } },
    { 'action': 'del', 'args': { 'body': { 'keys': ['list:a'] } } }];
  // Prints: "[ [ null, 'OK' ], [ null, '1' ], [ null, 1 ] ]"
  console.log(await kuzzle.ms.mexecute(actions));
} catch (error) {
  console.error(error.message);
}