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 Greater Than
- DynamoDB: Get List Of Items
- DynamoDB: GetItem
- DynamoDB: Get Last Inserted Item
- DynamoDB: Create if Not Exists
- DynamoDB: Query Date Range
- DynamoDB: Like
- DynamoDB: Delete Table
- DynamoDB: Increment Counter
- DynamoDB: Query KeyConditionExpression
- DynamoDB: Bulk Insert
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Get Multiple Items
- DynamoDB: BatchGetItem
- DynamoDB: Delete Multiple Items in Javascript
Tired of AWS Console? Try Dynobase.
Start your 7-day free trial today
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase