Reputation: 43
im trying to establish a connection to datastax astra-db using the node module cassandra-client
, as shown below
const client = new cassandra.Client({
cloud: { secureConnectBundle: 'path/to/secure-connect-DATABASE_NAME.zip' },
credentials: { username: 'user_name', password: 'p@ssword1' }
});
previously, we used to get the username
and password
from the Connection Details
tab in our DataBase section with the use this module where we got these required fields, but now it shows the usage of some other module which i dont want to use. I am not sure where to find these details, please guid me through.
I didn't find those fields anywhere on the dashboard and i am not sure if we need to use the username and password of our account.
Upvotes: 0
Views: 192
Reputation: 649
You have not produced additional information related to,
Having said that, I'm going to make an educated guess in answering your question here. If you were to update your original question with additional details, we could update the answer accordingly.
Connecting to the DataStax Astra DB Serverless cluster can be achieved by,
const cassandra = require('cassandra-driver');
const cloud = { secureConnectBundle: process.env['ASTRA_DB_SECURE_BUNDLE_PATH'] };
const authProvider = new cassandra.auth.PlainTextAuthProvider('token', process.env['ASTRA_DB_APPLICATION_TOKEN']);
const client = new cassandra.Client({ cloud, authProvider });
async function run() {
await client.connect();
// ...
}
Docs reference: https://docs.datastax.com/en/astra/astra-db-vector/databases/nodejs-driver.html
The application token aka credentials can be created & fetch by following this procedure.
In case, if you are using Astra DB Serverless (Vector) deployment type, it is recommended to leverage the Typescript client if you're dealing with just your JSON documents and don't want to worry about the data model. If you prefer using pure CQL, then continue with the above Node.js driver itself.
Other helpful resources:
4.7.2
.I hope that helps!
Follow-up question:
now it shows the usage of some other module which i dont want to use
You had mentioned above. Could you elaborate on why you don't want to use it? I believe you're referring to this connection guide which is also valid form of connection.
Upvotes: 1