DynamoDB: Get Unique Values (Guide w/ Code Examples)

Provided by Rafal Wilinski
To retrieve unique values from a DynamoDB table using the JavaScript SDK, you can use the query
or scan
operations and set the Distinct
parameter to true
. This will return only the unique values for the specified attribute.
But the scan
operation does not support Distinct
parameter, instead, you can use the filterExpression
to filter the unique values.
var params = { TableName: "myTable", Distinct: true, KeyConditionExpression: "#product = :product", ExpressionAttributeNames: { "#product": "product" }, ExpressionAttributeValues: { ":product": "myProduct" } }; dynamodb.query(params, function(err, data) { if (err) { console.log(err); } else { console.log(data); } });
Similar Code Examples
- DynamoDB: Query Items
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Not Between
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Query Group By
- DynamoDB: Like
- DynamoDB: Create if Not Exists
- DynamoDB: Get Query
- DynamoDB: Increment Counter
- DynamoDB: Get By ID
- DynamoDB: Query Greater Than
- DynamoDB: Query JSON
- DynamoDB: Get List Of Items
- DynamoDB: Get Last Inserted Item
- DynamoDB: Delete
Tired of AWS Console? Try Dynobase.
Try 7-day free trial. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase