Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why DynamoDB Query not Returning any Items in Low-Level Client? #6848

Closed
waleedshkt opened this issue Jan 24, 2025 · 1 comment
Closed

Why DynamoDB Query not Returning any Items in Low-Level Client? #6848

waleedshkt opened this issue Jan 24, 2025 · 1 comment

Comments

@waleedshkt
Copy link

waleedshkt commented Jan 24, 2025

Discussed in #6847

Originally posted by waleedshkt January 24, 2025
This may sound ridiculous to ask. But on a serious note, I am putting in an item in DynamoDB successfully using PutItemCommand. I confirm it by scanning for items in AWS console.

But on querying it, the QueryCommand is not returning any item (empty array)

Primary key is comprised of _type partition key and uid sort key. The sort key is hash (string)

Here is my code for querying to get al items with specific partition key:

import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
import { DynamoDBClient, QueryCommand } from "@aws-sdk/client-dynamodb";

const client = new DynamoDBClient({...credentials});
const res = await client.send(new QueryCommand({
   TableName: SOME_NAME,
   ScanIndexForward: false,
   KeyConditionExpression: "#_type = :type AND uid > :uid",
   ExpressionAttributeValues: marshall({
      ":type": "apple",
      ":uid": "0"
   }),
   ExpressionAttributeNames: {
      "#_type": "_type"
   },
}));

if(res) {
   return res.items.map(item => unmarshall (item));
}else{
   throw Error("Failed to fetch");
}

The item in dynamodb to query against has primary key: _type = 'apple' and uid = 'dh46dhdj3jdhd738'

What is possibly wrong? Is using an uncommon underscore prefix in partition key causing any breakage on dynamodb side?

Using

@aws-sdk/util-dynamodb@3.716.0
@aws-sdk/client-dynamodb@3.716.0
ap-south-1

Update:
I even checked it with ConsistentRead set to true. But the items are just not returning despite being able to do so in console with same query.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant