-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathtransact-get.js
44 lines (41 loc) · 1.4 KB
/
transact-get.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
36
37
38
39
40
41
42
43
44
// This is an example of a simple TransactGetCommand with the higher level DocumentClient for Amazon DynamoDB
const { DynamoDBClient } = require("@aws-sdk/client-dynamodb");
const { DynamoDBDocumentClient, TransactGetCommand } = require("@aws-sdk/lib-dynamodb");
async function transactGetItems() {
const client = new DynamoDBClient({ region: "us-west-2" });
const ddbDocClient = DynamoDBDocumentClient.from(client);
try {
return await ddbDocClient.send(
new TransactGetCommand({
TransactItems: [
{
Get: {
TableName: "RetailDatabase",
Key: {
pk: "[email protected]",
sk: "metadata",
},
},
},
{
Get: {
TableName: "RetailDatabase",
Key: {
pk: "[email protected]",
sk: "metadata",
},
},
},
],
//This returns an object with info on how much capacity the operation used and is optional.
ReturnConsumedCapacity: "TOTAL",
})
);
} catch (err) {
console.error(err);
}
}
transactGetItems()
.then((data) =>
console.log("TransactGetCommand succeeded:", JSON.stringify(data, null, 2)))
.catch((error) => console.error(JSON.stringify(error, null, 2)));