AshScylla.DataLayer.Batch (AshScylla v0.2.0)

Copy Markdown View Source

Batch operations support for AshScylla using ScyllaDB's BATCH statements.

ScyllaDB/Cassandra supports batch operations for executing multiple CQL statements in a single request.

Summary

Functions

Executes a batch of DELETE statements.

Executes a batch of INSERT statements.

Executes a batch of UPDATE statements.

Functions

batch_delete(repo, statements, opts \\ [])

(since 1.0.0)
@spec batch_delete(module(), [{String.t(), list()}], keyword()) ::
  {:ok, term()} | {:error, term()}

Executes a batch of DELETE statements.

batch_insert(repo, statements, opts \\ [])

(since 1.0.0)
@spec batch_insert(module(), [{String.t(), list()}], keyword()) ::
  {:ok, term()} | {:error, term()}

Executes a batch of INSERT statements.

Examples

statements = [
  {"INSERT INTO users (id, name) VALUES (?, ?)", [id1, "Alice"]},
  {"INSERT INTO users (id, name) VALUES (?, ?)", [id2, "Bob"]}
]

DataLayer.Batch.batch_insert(repo, statements)

batch_update(repo, statements, opts \\ [])

(since 1.0.0)
@spec batch_update(module(), [{String.t(), list()}], keyword()) ::
  {:ok, term()} | {:error, term()}

Executes a batch of UPDATE statements.