Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
copy DynamoDB items to another table
import AWS from 'aws-sdk'
const db = new AWS.DynamoDB();
const oldTable = 'bifravst-cellGeolocationdeviceCellGeoLocations9F25FBED-1VK9FPSS5GX3G'
const newTable = 'bifravst-cellGeolocationdeviceCellGeoLocation757F8D27-1K6Z9IBMWMV2K'
const refill = (ExclusiveStartKey) => db.scan({
TableName: oldTable,
Limit: 100,
ExclusiveStartKey
}).promise()
.then(async ({ LastEvaluatedKey, Items }) => {
console.dir(Items, { depth: 10 })
await Promise.all(Items.map(Item => db.putItem({
Item,
TableName: newTable
}).promise()))
if (LastEvaluatedKey) return refill(LastEvaluatedKey)
})
refill()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment