-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.js
More file actions
29 lines (24 loc) · 708 Bytes
/
Copy pathdelete.js
File metadata and controls
29 lines (24 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let AWS = require('aws-sdk')
let tableName = 'REPLACE'
let accessKeyId = 'REPLACE'
let secretAccessKey= 'REPLACE'
// id key of the item you want to delete
let keyToDelete = 'REPLACE'
AWS.config.update({
region: 'ap-southeast-1',
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey}
})
let docClient = new AWS.DynamoDB.DocumentClient()
let params = {
TableName: tableName,
Key: {
id: keyToDelete
}
}
docClient.delete(params, (err, data) => {
if (err)
return console.error("Unable to delete. Error JSON:", JSON.stringify(err, null, 2));
console.log("Delete succeeded for id:", keyToDelete)
console.log("DynamoDB response:", JSON.stringify(data, null, 2))
})