Migrating your DataStax Node.js driver to connect with Apollo databases

Migrate your existing DataStax Node.js driver to a version compatible with Cassandra databases.

Complete the following procedure to migrate your existing DataStax Node.js driver to a version that is capable of connecting to Apollo databases created using DataStax Apollo on Constellation.

Prerequisites

  1. Create a DataStax Apollo database.
  2. Download the secure connect bundle to obtain connection credentials for your DataStax Apollo database.

Procedure

  1. Install the DataStax Node.js driver:
    • DataStax Node.js driver for Apache Cassandra

      npm install cassandra-driver
    • DSE driver

      npm install dse-driver
  2. In your existing DataStax Node.js driver code, modify the connection code to use the DataStax Apollo on Constellation API.

    Include the absolute path to the secure connect bundle for your Cassandra database (secure-connect-database_name.zip) in the secureConnectBundle parameter, as shown in the following examples.

    • DataStax Node.js driver for Apache Cassandra

      const { Client } = require('cassandra-driver');
      
      const client = new Client({
          cloud: { secureConnectBundle: 'path/to/secure-connect-database_name.zip' },
          credentials: { username: 'username', password: 'password' }
        });
      
    • DSE Node.js driver

      const dse = require('dse-driver');
      
      const client = new Client({
          cloud: { secureConnectBundle: 'path/to/secure-connect-database_name.zip' },
          credentials: { username: 'username', password: 'password' }
        });
      
  3. Run your Node.js script to connect to your Apollo database.
    node my_node.js_driver.js

    If successful, the code builds, compiles, and connects to your Cassandra database.