-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathupdate.js
35 lines (29 loc) · 1007 Bytes
/
update.js
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
30
31
32
33
34
35
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "node:url";
// snippet-start:[dynamodb.JavaScript.docClient.updateV3]
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, UpdateCommand } from "@aws-sdk/lib-dynamodb";
const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);
export const main = async () => {
const command = new UpdateCommand({
TableName: "Dogs",
Key: {
Breed: "Labrador",
},
UpdateExpression: "set Color = :color",
ExpressionAttributeValues: {
":color": "black",
},
ReturnValues: "ALL_NEW",
});
const response = await docClient.send(command);
console.log(response);
return response;
};
// snippet-end:[dynamodb.JavaScript.docClient.updateV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}