DynamoDB: Query JSON (Guide w/ Code Examples)
Provided by Rafal Wilinski
JavaScript AWS SDK does not provide a specific method to query data as JSON. But you can use the query
operation to get data as an array and pass the result to JSON.stringify
method to convert the array to a JSON string.
const AWS = require('aws-sdk'); const dynamoDb = new AWS.DynamoDB.DocumentClient(); const params = { TableName: 'tableName', KeyConditionExpression: 'primaryKey = :primaryKeyValue', ExpressionAttributeValues: { ':primaryKeyValue': 'value' } }; dynamoDb.query(params, (error, data) => { if (error) { console.error(error); return; } console.log(JSON.stringify(data.Items)); });
Similar Code Examples
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: BatchGetItem
- DynamoDB: Query Ends With
- DynamoDB: Get Unique Values
- DynamoDB: Get Random Item
- DynamoDB: Get Multiple Items
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Query KeyConditionExpression
- DynamoDB: Not Begins With
- DynamoDB: Delete Table
- DynamoDB: Like
- DynamoDB: Get Query
- DynamoDB: Get List Of Items
- DynamoDB: Query Greater Than
- DynamoDB: Query Items
Tired of switching accounts and regions? Use Dynobase.
First 7 days are on us. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2024 Dynobase