Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save serhatcan/9e8c77e774ca3a6f495d8aabcd7eebd6 to your computer and use it in GitHub Desktop.
Save serhatcan/9e8c77e774ca3a6f495d8aabcd7eebd6 to your computer and use it in GitHub Desktop.
var params = {
TableName: 'table_name',
};
docClient.scan(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else {
data.Items.forEach(function(obj,i){
console.log(i);
console.log(obj);
var params = {
TableName: 'chatUserMapping',
Key: { // a map of attribute name to AttributeValue for all primary key attributes
"sampleHashKey": obj.sampleHashKey,
"sampleRangeKey": obj.sampleRangeKey
// more attributes...
},
ReturnValues: 'NONE', // optional (NONE | ALL_OLD)
ReturnConsumedCapacity: 'NONE', // optional (NONE | TOTAL | INDEXES)
ReturnItemCollectionMetrics: 'NONE', // optional (NONE | SIZE)
};
docClient.delete(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
});
}
});
dynamodb.listTables().eachPage(function(err, data) {
if (err) {
ppJson(err); // an error occurred
} else if (data) {
console.log(data);
data["TableNames"].forEach(function(tablename, i) {
console.log(tablename);
var params = {
TableName: tablename,
};
dynamodb.deleteTable(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment