Represents a Cassandra table, encapsulating functionality for schema definition, data manipulation, and querying. This class provides a high-level abstraction over Cassandra's table operations, including creating tables, inserting, updating, selecting, and deleting records. It leverages the CassandraClient for executing operations and supports asynchronous interactions with the database.
Key features include:
The class is designed to be instantiated with a set of configuration arguments (CassandraTableArgs)
that define the table's structure and operational parameters, providing a streamlined interface for
interacting with Cassandra tables in a structured and efficient manner.
Usage Example:
const tableArgs: CassandraTableArgs = {
table: 'my_table',
keyspace: 'my_keyspace',
primaryKey: [{ name: 'id', type: 'uuid', partition: true }],
nonKeyColumns: [{ name: 'data', type: 'text' }],
};
const cassandraClient = new CassandraClient(clientConfig);
const myTable = new CassandraTable(tableArgs, cassandraClient);
This class simplifies Cassandra database interactions, making it easier to perform robust data operations while maintaining clear separation of concerns and promoting code reusability.
class CassandraTableDeletes rows from the Cassandra table that match the specified WHERE clause conditions.
Asynchronously obtains a configured Cassandra client based on the provided arguments. This method processes the given CassandraClientArgs to produce a configured Client instance from the cassandra-driver, suitable for interacting with Cassandra databases.
Executes a SELECT query on the Cassandra table with optional filtering, ordering, and pagination. Allows for specifying columns to return, filter conditions, sort order, and limits on the number of results.
Inserts or updates records in the Cassandra table in batches, managing concurrency and batching size.
This method organizes the provided values into batches and uses _upsert to perform the database operations.