Skip to main content

Step 4: Reading

In this step, we will read data we wrote to the database in Step 3

Fetching a single item

To fetch a single item, use the getItem method. Let's fetch the item with the key job#1:

  const document = await client.getItem({databaseId, key: 'job#1'});
console.log(document);

Listing all items

To list all items in the database, use the listItems method. By default, this method returns 1,000 items. You can paginate through the results by passing the nextToken returned in the response.

  const documents = await client.listItems({databaseId});
console.log(`Found ${documents.items.length} documents`)
console.log(documents);