How to query with partition key in Amazon DynamoDB using the AWS SDK for JavaScript

Viewed 1689

I'm new to Amazon DynamoDB and I want to get records according to creator id. I made one partition key and after made query

 var params = {

    TableName: process.env.TABLE_PARTS,
     IndexName: "createdBy-index",
      KeyConditionExpression: "createdBy = :createdBy",
      ExpressionAttributeValues: {":createdBy": "abus282jehbhwdubunids"}
      
   }
  
  const data = await db.query(params).promise();

  res.send(data);

But I am getting data = null

1 Answers

To learn how to successfully use the AWS SDK for JavaScript to query Amazon DynamoDB tables, see the AWS SDK for JavaScript DEV Guide. Specifically refer to this topic:

Amazon DynamoDB examples

See the example under Getting an item.

This DEV guide has the information you need to successfully use this SDK.

Related