DynamoDB: Get Query (Guide w/ Code Examples)

Provided by Rafal Wilinski
To query a table in Amazon DynamoDB using the JavaScript SDK, you can use the query
method on the DynamoDB DocumentClient
. The query method takes an object that specifies the parameters of the query.
const AWS = require('aws-sdk'); const dynamoDb = new AWS.DynamoDB.DocumentClient(); const params = { TableName: 'myTable', KeyConditionExpression: '#key = :value', ExpressionAttributeNames: { '#key': 'key', }, ExpressionAttributeValues: { ':value': 'value', }, }; dynamoDb.query(params, (err, data) => { if (err) { console.error('Error:', err); } else { console.log('Data:', data); } });
It is important to note that the query method will only return items with the specified primary key value, and the primary key must be specified in the KeyConditionExpression
parameter.
Similar Code Examples
- DynamoDB: Query Items
- DynamoDB: Query Ends With
- DynamoDB: Not Begins With
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Get Table
- DynamoDB: Get Unique Values
- DynamoDB: Create if Not Exists
- DynamoDB: Get Last 10 Records
- DynamoDB: Not Between
- DynamoDB: Attribute Not Null
- DynamoDB: Get Random Item
- DynamoDB: Get By ID
- DynamoDB: Query Date Range
- DynamoDB: Delete
- DynamoDB: Query Global Secondary Index in Nodejs
Tired of AWS Console? Try Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase