CassandraStore, a wide-column implementationNoSqlStore interface. Queries are CQL, which looks like SQL but is$ docker run -d --name orm-cassandra \
-p 9042:9042 \
-e CASSANDRA_CLUSTER_NAME=orm_test \
cassandra:5$ docker compose up -d --wait # returns once the healthcheck passes
$ docker compose down -v # tear down, volumes included$ until docker exec orm-cassandra cqlsh -e 'DESCRIBE KEYSPACES' >/dev/null 2>&1; do sleep 2; donedocker ps showing "healthy" is not sufficient — CQL accepts connections after$ docker exec orm-cassandra cqlsh -e "
$ CREATE KEYSPACE IF NOT EXISTS app
$ WITH replication = {'class':'SimpleStrategy','replication_factor':1};"SimpleStrategy with RF 1 is for local development only. Production usesNetworkTopologyStrategy with a replication factor per data centre.$ npm install ts-prorm-orm cassandra-driverimport { CassandraStore } from 'ts-prorm-orm/nosql/cassandra';
const store = new CassandraStore({
contactPoints: ['127.0.0.1'],
localDataCenter: 'datacenter1', // required by the default load-balancing policy
keyspace: 'app',
credentials: { username: 'cassandra', password: 'cassandra' },
});
await store.connect();
try {
await store.execute(`
CREATE TABLE IF NOT EXISTS users (
id uuid PRIMARY KEY,
name text,
age int
)`);
await store.execute(
'INSERT INTO users (id, name, age) VALUES (?, ?, ?)',
[crypto.randomUUID(), 'Ada', 30],
);
const rows = await store.execute('SELECT * FROM users');
console.log(rows.length);
} finally {
await store.disconnect();
}import { CassandraStore } from 'ts-prorm-orm/nosql/cassandra';
const store = new CassandraStore({
keyspace: 'app',
credentials: { username: 'token', password: process.env.ASTRA_DB_APPLICATION_TOKEN! },
clientOptions: { cloud: { secureConnectBundle: './secure-connect-app.zip' } },
});
await store.connect();localDataCenter is not optional — the default load-balancing policy refusesdatacenter1.WHERE only on the partition key and clustering columns, unless you addALLOW FILTERING — which scans the cluster andORDER BY on arbitrary columns — only clustering columns, in their[!WARNING] Known limitations The container needs 1 GB or more of memory; cap the heap ( MAX_HEAP_SIZE) on small CI runners or it is OOM-killed.Reads should name the partition key: use the compiled findAll/selectPage, which refuses scans at build time, rather than hand-writtenSELECT *.Schema changes ( CREATE TABLE) propagate asynchronously across a real cluster; wait for schema agreement before writing.
$ docker rm -f orm-cassandra| Symptom | Cause |
|---|---|
NoHostAvailableError right after start | Still bootstrapping. Poll cqlsh, not the port. |
localDataCenter could not be determined | Set it explicitly; the image uses datacenter1. |
Keyspace 'app' does not exist | The image creates none — run the CREATE KEYSPACE above. |
| Container killed on start | Cassandra wants ~2 GB; raise the Docker memory limit. |
ALLOW FILTERING demanded | The WHERE is not on the partition key — remodel the table. |