Registry / database / express-cassandra

express-cassandra

JSON →
library2.9.1jsnpmunverified

Express-Cassandra is a Cassandra ORM/ODM/OGM for NodeJS supporting Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra, and JanusGraph. Current stable version is 2.9.1. It provides automatic model loading, schema management, CRUD operations, materialized views, secondary indexes, and advanced features like streaming, token-based pagination, and batching. Key differentiators include support for multiple Cassandra-compatible databases, elasticsearch integration via Elassandra, and graph database support. Uses the official cassandra-driver internally. Released under MIT license with active maintenance.

npm install express-cassandra
INSTALL
IMPORT
SIG · EXPRESS-CASSANDRA
E
express-cassandra
databasejavascriptv2.9.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ExpressCassandra
import expressCassandra from 'express-cassandra';
const expressCassandra = require('express-cassandra');
Default export is the main client constructor. CommonJS require still works.
models
const models = require('express-cassandra').models;
import { models } from 'express-cassandra';
The package does not export named 'models'; access via the client instance after calling .connect().
client
const client = new expressCassandra({...});
const client = expressCassandra.createClient({...});
The client is instantiated with 'new', not a factory method.
Model
import { Model } from 'express-cassandra';
import Model from 'express-cassandra';
Model is a named export for custom model definitions. Available since v2.

Initializes and connects an express-cassandra client with contact points and ORM options, including keyspace creation.

import expressCassandra from 'express-cassandra'; const client = new expressCassandra({ clientOptions: { contactPoints: [process.env.CASSANDRA_HOST ?? '127.0.0.1'], keyspace: 'mykeyspace', localDataCenter: 'datacenter1', protocolOptions: { port: 9042 } }, ormOptions: { defaultReplicationStrategy: { class: 'SimpleStrategy', replication_factor: 1 }, migration: 'safe', createKeyspace: true } }); client.connect((err) => { if (err) { console.error(err); process.exit(1); } console.log('Connected to Cassandra'); }); export default client;
Debug
Known issues
breakingIn version 2.0, the module renamed exports. 'express-cassandra' now exports a constructor, not an object with a 'connect' method.
fix
Use `new expressCassandra({...})` instead of `expressCassandra.connect({...})`.
affects: >=2.0.0 <3.0.0
deprecatedThe `.async()` suffix methods (e.g., `saveAsync`) are deprecated in favor of promise-based methods on the driver.
fix
Use native promises with `.save()` or the returned promise from methods.
affects: >=2.5.0
gotchaDefault export is a constructor, not a factory. Forgetting `new` leads to 'Cannot read property of undefined' errors.
fix
Always use `new expressCassandra(...)` when creating a client instance.
affects: all
gotchaModel loading expects files in the `models` directory by default. Custom path must be provided in options.
fix
Set `ormOptions.modelsDirectory` in client options to specify a custom path.
affects: all
breakingcassandra-driver v4.x removed the `raw` option from query methods. express-cassandra may break if using query options that depend on removed features.
fix
Ensure cassandra-driver version is compatible. Check express-cassandra documentation for driver version combinations.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: expressCassandra is not a constructor
Missing 'new' keyword when instantiating the client.
fix
Use `const client = new expressCassandra({...});`
Error: connect ECONNREFUSED 127.0.0.1:9042
Cassandra server is not running or not reachable at the given host/port.
fix
Start Cassandra/ScyllaDB server or check contactPoints configuration.
Error: Keyspace 'mykeyspace' does not exist
The keyspace specified in options does not exist and automatic creation is disabled.
fix
Set `ormOptions.createKeyspace: true` or create the keyspace manually.
Cannot find module '../lib/model'
Model directory path is incorrect or model files are missing.
fix
Check `ormOptions.modelsDirectory` path and ensure model files exist.
Upgrade
Version history
2.9.1latest on npm
Audit
Dependencies
cassandra-driverrequiredCore driver for Cassandra connectivity
Agent activity
38 hits · last 30 days
node
36
Amazon
1
Resources
express-cassandra — npm install express-cassandra · libregistry