Amazon QLDB Driver for Node.js - Amazon Quantum Ledger Database (Amazon QLDB)

Amazon QLDB Driver for Node.js

To work with data in your ledger, you can connect to Amazon QLDB from your Node.js application by using an AWS-provided driver. The following sections describe how to get started with the QLDB Driver for Node.js.

Driver Resources

For more information about the functionality supported by the Node.js driver, see the following resources:

Prerequisites

Before you get started with the QLDB Driver for Node.js, you must do the following:

  1. Follow the AWS setup instructions in Accessing Amazon QLDB. This includes signing up for AWS and getting an AWS access key for development.

  2. Install Node.js version 10.x or later from the Node.js downloads site.

  3. Configure your development environment for the AWS SDK for JavaScript in Node.js:

Next, you can download the complete tutorial sample application—or you can install only the driver in an existing Node.js project and run some code examples.

  • To install only the QLDB Driver and the AWS SDK for JavaScript in Node.js in an existing project, proceed to Installation (Driver Only).

  • To run short code examples that execute basic data transactions on a ledger, see the Quick start guide.

  • To run more in-depth examples of both data and control plane operations in the complete tutorial sample application, see the Node.js Tutorial.

Installation (Driver Only)

To install the QLDB Driver using npm (the Node.js package manager), enter the following command from your project root directory.

npm install amazon-qldb-driver-nodejs@1.0.0

Installing the driver also installs TypeScript 3.5.x as a dependency.

In addition, the driver has peer dependencies on aws-sdk (AWS SDK for JavaScript), ion-js (Amazon Ion data format), and jsbi (pure JavaScript implementation of BigInt). You must also install these packages as dependencies in your project.

npm install aws-sdk
npm install ion-js@4.0.0
npm install jsbi@3.1.2

Using the driver to connect to a ledger

Then you can import the driver and use it to connect to a ledger. The following TypeScript code example shows how to create a driver instance for a specified ledger name and AWS Region.

import { QldbDriver } from "amazon-qldb-driver-nodejs"; const testServiceConfigOptions = { region: "us-east-1" }; const qldbDriver: QldbDriver = new QldbDriver("testLedger", testServiceConfigOptions); qldbDriver.getTableNames().then(function(tableNames: string[]) { console.log(tableNames); });

For short code examples of how to run basic data transactions on a ledger, proceed to the Quick start guide. For more in-depth examples that demonstrate both data and control plane operations in a full sample application, see the Node.js Tutorial.