-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
put-item.js
32 lines (26 loc) · 1.13 KB
/
put-item.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "url";
// snippet-start:[dynamodb.JavaScript.item.putItemV3]
import { PutItemCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({});
export const main = async () => {
const command = new PutItemCommand({
TableName: "Cookies",
// For more information about data types,
// see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes and
// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.DataTypeDescriptors
Item: {
Flavor: { S: "Chocolate Chip" },
Variants: { SS: ["White Chocolate Chip", "Chocolate Chunk"] },
},
});
const response = await client.send(command);
console.log(response);
return response;
};
// snippet-end:[dynamodb.JavaScript.item.putItemV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}