DynamoDB BatchWriteItem in Typescript (Guide w/ Code Examples)

Provided by Rafal Wilinski
The batchWriteItem method in AWS JavaScript SDK can be used to write multiple items to one or more tables in a single request. In TypeScript, you can use the aws-sdk library to interact with DynamoDB. Here's an example of how you can use the batchWriteItem method in a TypeScript function:
import * as AWS from 'aws-sdk'; const dynamoDb = new AWS.DynamoDB.DocumentClient(); export async function batchWriteItems(items: any[], tableName: string) { const params = { RequestItems: { [tableName]: items.map((item: any) => ({ PutRequest: { Item: item } })) } }; try { const data = await dynamoDb.batchWrite(params).promise(); console.log(data); return data; } catch (err) { console.log(err); throw new Error(err); } }
Similar Code Examples
- DynamoDB: Query KeyConditionExpression
- DynamoDB: Bulk Insert
- DynamoDB: BatchGetItem
- DynamoDB: Query Date Range
- DynamoDB: Get Last Inserted Item
- DynamoDB: Get Unique Values
- DynamoDB: Query JSON
- DynamoDB: Get All Items
- DynamoDB: Create if Not Exists
- DynamoDB: Query Count
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Increment Counter
- DynamoDB Get in Typescript
- DynamoDB: Not Begins With
- DynamoDB: Query Group By
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
- New in Dynobase 3.0
- Semantic and Vector Search
- Schema Explorer
- Visual JSON Path Filtering
- Visual Item Diff
- MCP Server for AI Tools
- Use SQL with DynamoDB
- Import CSV To DynamoDB
- Import JSON To DynamoDB
- Export DynamoDB To JSON
- Export DynamoDB To S3
- Export DynamoDB To CSV
- DynamoDB Update Item
- DynamoDB Delete All Items
- DynamoDB Delete Item
- DynamoDB Create Table
- DynamoDB Delete Table
- DynamoDB Conditional Update
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase