Set your environment variables
To use the Connect your app to DataStax Astra DB using the Document API in node.js.
The Astra DB Collection Node.js Client connects to the Astra DB Document API.
Set up your environment
-
Install the Astra DB JS Collection:
npm install @astrajs/collections
-
Open a browser, navigate to Astra DB, and log in.
-
From your Dashboard page, select your database.
-
Copy the Cluster ID of your database.
You can also find the Cluster ID in the URL, which is the last UUID in the path:
https://astra.datastax.com/org/{org-Id}/database/{databaseid}
-
Add the Cluster ID as an environment variable with the following command:
export ASTRA_DB_ID={databaseid}
Example
export ASTRA_DB_ID=b5285f63-8da5-4c6e-afd8-ade371a48795
-
Copy the Region of your database, the region where your database is located.
-
Add the Region as an environment variable with the following command:
export ASTRA_DB_REGION={region}
Example
export ASTRA_DB_REGION=us-east1
-
Add your username and your password as environment variables with the following command:
Get Client ID and Client Secret by creating your application token for your username and password. |
export ASTRA_DB_USERNAME=clientId
export ASTRA_DB_PASSWORD=clientSecret
-
Use
printenv
to ensure the environment variables were exported.