Migrating Node.js driver
Complete the following procedure to migrate your existing DataStax Node.js driver to a version that is capable of connecting to Astra DB databases created using DataStax Astra DB.
-
Install the DataStax Node.js driver:
-
In your existing DataStax Node.js driver code, modify the connection code to use the Astra DB API. Include the absolute path to the secure connect bundle for your Cassandra database (
secure-connect-database_name.zip
) in thesecureConnectBundle
parameter, as shown in the following examples.const { Client } = require('cassandra-driver'); const client = new Client({ cloud: { secureConnectBundle: 'path/to/secure-connect-database_name.zip' }, credentials: { username: 'clientId', password: 'clientSecret' } });
const dse = require('dse-driver'); const client = new Client({ cloud: { secureConnectBundle: 'path/to/secure-connect-database_name.zip' }, credentials: { username: 'clientId', password: 'clientSecret' } });
-
Run your Node.js script to connect to your Astra DB database:
node my_node.js_driver.js
If successful, the code builds, compiles, and connects to your Cassandra database.