{"id":44075,"library":"tyb-express-cassandra","title":"Express-Cassandra","description":"Express-Cassandra is a framework-independent Cassandra Object Models (ORM) for NodeJS that wraps the DataStax DSE driver (based on cassandra-driver). Version 1.9.3 supports Cassandra 3.x with features like CRUD operations, data type validations, materialized views, secondary/custom/SASI indexes, user-defined types, batch operations, hook functions, automatic migrations, and promise support via Async suffixed functions. It is compatible with Express, Restify, Hapi, Koa, and more. Note: legacy Cassandra 2.x users must use version 0.5.4. The ORM is built on a highly modified version of apollo-cassandra.","status":"active","version":"1.9.3","language":"javascript","source_language":"en","source_url":"git://github.com/masumsoft/express-cassandra","tags":["javascript","cassandra","orm","model","db","node","nodejs","express","expressjs"],"install":[{"cmd":"npm install tyb-express-cassandra","lang":"bash","label":"npm"},{"cmd":"yarn add tyb-express-cassandra","lang":"bash","label":"yarn"},{"cmd":"pnpm add tyb-express-cassandra","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Official DataStax driver for Apache Cassandra and DSE; provides all Cassandra connectivity","package":"dse-driver","optional":false}],"imports":[{"note":"Default export is the model container. Use import models from 'express-cassandra' (ESM). For CommonJS, use const models = require('express-cassandra');","wrong":"const models = require('express-cassandra');","symbol":"default","correct":"import models from 'express-cassandra'"},{"note":"Named export for creating model definitions. Not commonly needed; usual pattern is to call models.connect() and then models.load().","wrong":"const { Model } = require('express-cassandra');","symbol":"Model","correct":"import { Model } from 'express-cassandra'"},{"note":"Exports Cassandra data types (e.g., types.TimeUuid) for use in model schemas.","wrong":null,"symbol":"types","correct":"import { types } from 'express-cassandra'"}],"quickstart":{"code":"const models = require('express-cassandra');\n\nmodels.setDirectory(__dirname + '/models').bind({\n  clientOptions: {\n    contactPoints: ['127.0.0.1'],\n    protocolOptions: { port: 9042 },\n    keyspace: 'mykeyspace'\n  },\n  ormOptions: {\n    defaultReplicationStrategy: {\n      class: 'SimpleStrategy',\n      replication_factor: 1\n    },\n    migration: 'safe'\n  }\n});\n\nconst User = models.load('User', {\n  fields: {\n    id: { type: 'uuid', default: { $db_function: 'uuid()' } },\n    name: { type: 'text' },\n    email: { type: 'text' }\n  },\n  key: ['id']\n});\n\nmodels.connect(function(err) {\n  if (err) throw err;\n  const user = new User({ name: 'John', email: 'john@example.com' });\n  user.saveAsync().then(() => console.log('User saved'));\n});","lang":"javascript","description":"Initializes the ORM, connects to a local Cassandra instance, defines a User model, saves a record using promises."},"warnings":[{"fix":"Migrate to dse-driver API or use express-cassandra@0.5.4 for Cassandra 2.x.","message":"Version 1.0 switched from cassandra-driver to dse-driver, breaking compatibility with older Cassandra versions and changing API methods.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Replace .save() with .saveAsync() and handle with then/catch or async/await.","message":"The .save() callback-based method is deprecated; use .saveAsync() which returns a promise.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use const models = require('express-cassandra')() or const models = require('express-cassandra').connect({...}).","message":"Default export is a factory function, not the ORM instance itself. Calling require('express-cassandra') returns a function you must invoke with configuration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set ormOptions.migration: 'safe' in the bind() call.","message":"Migration mode 'alter' can drop columns automatically. Use 'safe' to avoid unintended schema changes.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"npm install express-cassandra (not tyb-express-cassandra).","message":"The package name on npm is 'express-cassandra', but the GitHub repository is 'tyb-express-cassandra'. Ensure you install the correct one.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'0.5.4':83 '1.9.3':30 '2':77 '3':33 'apollo':95 'apollo-cassandra':94 'async':61 'automat':55 'base':24 'batch':51 'built':87 'cassandra':3,6,12,27,32,76,96,98 'cassandra-driv':26 'compat':66 'crud':38 'data':40 'datastax':21 'db':101 'defin':49 'driver':23,28 'dse':22 'express':2,5,68,104 'express-cassandra':1,4 'expressj':105 'featur':36 'framework':10 'framework-independ':9 'function':54,63 'hapi':70 'high':90 'hook':53 'independ':11 'index':46 'javascript':97 'koa':71 'legaci':75 'like':37 'materi':43 'migrat':56 'model':14,100 'modifi':91 'must':80 'node':102 'nodej':17,103 'note':74 'object':13 'oper':39,52 'orm':15,85,99 'promis':58 'restifi':69 'secondary/custom/sasi':45 'suffix':62 'support':31,59 'type':41,50 'use':81 'user':48,79 'user-defin':47 'valid':42 'version':29,82,92 'via':60 'view':44 'wrap':19 'x':34,78","created_at":"2026-06-05T17:02:51.475783+00:00","updated_at":"2026-06-05T17:02:51.475783+00:00","problems":[{"fix":"npm install dse-driver","cause":"The package 'dse-driver' is a peer dependency that must be installed separately.","error":"Error: Cannot find module 'dse-driver'"},{"fix":"Correct usage: const models = require('express-cassandra'); models = models.bind({...}); then models.load('User', schema);","cause":"Default export is a function; you must call it with .bind() or .connect() before using .load().","error":"TypeError: models.load is not a function"},{"fix":"Ensure Cassandra is started on 127.0.0.1:9042, or update contactPoints and port in clientOptions.","cause":"Cassandra is not running or not reachable at the specified contact point.","error":"All host(s) tried for query failed. First host tried, 127.0.0.1:9042: Error: connect ECONNREFUSED 127.0.0.1:9042"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/masumsoft/express-cassandra","github":"git://github.com/masumsoft/express-cassandra","docs":null,"changelog":null,"pypi":null,"npm":"tyb-express-cassandra","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}