question

DLazeroms avatar image
DLazeroms asked Erick Ramirez edited

Struggling to connect to Astra DB with Node.js driver following the workshop series from July 2020

First of all, I am new to these kind of things, so this is probably a noob question.

I am following the 8-part Cassandra course on YouTube and in the third video (link to video), they go over connecting with Cassandra with a driver, for example on Gitpod. I believe that since then, some things have changed with the params for making connections (clientId and client secret). So instead of the "db_connection.js" used in the video, I added an "connect-database.js" as suggested on the tab Connect > Connect using a driver > Node.js on Astra and changed the references from db_connection.js to connect-database.js.

When I run

node connect-database.js

I get the response "Hello from cluster: cndb", which looks to me like I managed to get a connection.

Then, when I follow along the tutorial and go to exercise 2 in "Ex02_Connect_to_Cassandra.js". In the first line I changed "db_connection.js " > "connect-database.js ":

const connection = require('./connect-database');
const Uuid       = require('cassandra-driver').types.Uuid;

console.log("========================================")
console.log("Start exercise")

connection.client
.execute('SELECT * FROM system.local')
.then(function(result) {
result.rows.forEach(row => {
        console.log("Your are now connected to cluster '%s'", row.cluster_name)
    })
    connection.client.shutdown()
    console.log("SUCCESS")
})
.catch(function(error){
    console.log(error.message)
    connection.client.shutdown()
});

console.log("========================================")

and I run:

node Ex02_Connect_to_Cassandra.js 

I get the response "TypeError: Cannot read properties of undefined (reading 'execute') at Object.<anonymous> (/workspace/cassandra-workshop-series/week3-AppDev-crud/crud-nodejs/Ex02_Connect_to_Cassandra.js:8:2)". Which suggests to me that something is going wrong at the "execute" half way, but I can't figure out how to solve this.

astra dbnode.js driver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

DLazeroms avatar image
DLazeroms answered

Already solved it by just following the instructions on Astra instead of the tutorial.

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.