cassandra-nodejs-driver

A modern, highly tunable Node.js client for Apache Cassandra, DSE, HCD, and DataStax Astra DB with a built-in object mapper.

SDK
npm
v4.9.0
1,269stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity64
Maintenance20
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture84
Code Quality82
Innovation70
Learning Curve75

cassandra-driver is the Node.js client library for Apache Cassandra, donated to and maintained under the Apache Cassandra project (formerly DataStax’s driver). It speaks Cassandra’s native binary protocol and CQL directly, giving Node.js applications control over connection pooling, load balancing, and retry behavior when talking to a Cassandra cluster, DataStax Enterprise, Hyper-Converged Database (HCD), or DataStax Astra DB.

Beyond raw query execution, the driver ships a built-in object mapper for interacting with Cassandra tables as JavaScript documents, first-class support for prepared and batch statements, row streaming for large result sets, and native TypeScript typings. Both promise-based and callback-based APIs are supported, and the driver automatically discovers cluster topology and reconnects around node failures.

What You Get

  • Full CQL client with simple, prepared, and batch statement support
  • Built-in object mapper for working with Cassandra rows as JavaScript documents
  • Configurable load-balancing, retry, reconnection, and speculative-execution policies
  • Automatic cluster node discovery and transparent reconnection
  • Native TypeScript type definitions alongside promise- and callback-based APIs
  • Row streaming via eachRow()/stream() so large result sets aren’t buffered in memory
  • Support for Cassandra, DSE, HCD, and DataStax Astra DB (via secure connect bundle)

Common Use Cases

  • Powering high-throughput services backed by a Cassandra or DSE cluster
  • Connecting Node.js apps to DataStax Astra DB with a secure connect bundle
  • Streaming large analytical result sets row-by-row without loading them into memory
  • Modeling application data as JS objects via the built-in mapper instead of hand-writing CQL

Under The Hood

Architecture The driver is layered around a central Client (lib/client.js) that delegates connection lifecycle to a ControlConnection (lib/control-connection.js) for topology discovery and schema metadata, per-host HostConnectionPool instances (lib/host-connection-pool.js) for pooled sockets, and a RequestHandler/RequestExecution pair (lib/request-handler.js, lib/request-execution.js) that applies load-balancing and retry policies per query. Prepared statements route through a dedicated PrepareHandler, and the object mapper (lib/mapping/) sits on top of Client as an independent layer translating between CQL rows and JS model objects. This separation means the core execution pipeline, pooling layer, and mapper can each evolve independently; changing the base Client execution contract is the one change that would ripple through every layer above it. Score: 84/100

Tech Stack Written in plain JavaScript (CommonJS, 'use strict') targeting Node.js >=20, with hand-maintained TypeScript declarations (index.d.ts) rather than a TS build step. Runtime dependencies are minimal and deliberate: long for 64-bit integer handling over the wire protocol and adm-zip for reading Astra DB’s secure-connect-bundle archives. Dev tooling uses Mocha/Chai/Sinon for tests, ESLint (eslint:recommended plus custom rules) for linting, and a mix of GitHub Actions and a legacy Jenkins/AppVeyor CI setup reflecting its long history as a DataStax project before its Apache donation. Score: 78/100

Code Quality Tests are extensive: 121+ files across test/unit, test/integration/short, test/integration/long, and test/other/memory, covering the mapper, graph, geometry, and cloud (Astra) code paths, run via Mocha with Sinon for stubs and Proxyquire for dependency injection in unit tests. Error handling uses a proper typed hierarchy (lib/errors.js): a DriverError base with specific subclasses (NoHostAvailableError, ResponseError, AuthenticationError, OperationTimedOutError, BusyConnectionError, etc.), each carrying structured context rather than bare strings. Naming is consistent and every public method carries JSDoc. CI runs ESLint, TypeScript declaration compilation checks across multiple TS versions, and unit/integration suites on every push. Score: 82/100

What Makes It Unique Unlike most Node.js database clients that wrap a lower-level protocol library, this driver implements Cassandra’s binary protocol and CQL encoding/decoding directly, including full support for Cassandra’s richer type system (UDTs, collections, decimal/varint/bigint) that has no native JavaScript equivalent. It also bundles a document-style object mapper and DataStax Graph/geometry type support in the same package, and is one of the few Node.js DB clients built specifically to support both a traditional self-managed cluster and a fully managed cloud database (Astra DB) through the same client API and secure-connect-bundle mechanism. Score: 70/100

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search