-
Notifications
You must be signed in to change notification settings - Fork 634
Description
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/[email protected]
@aws-sdk/[email protected]
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.