Skip to content

Commit 31affaf

Browse files
brmurcpyle0819
andauthored
Updates to PartiQL scenarios
* Updates to PartiQL scenarios * Updates to PartiQL scenarios Co-authored-by: Corey Pyle <corepyle@amazon.com>
1 parent f2c2256 commit 31affaf

26 files changed

+6281
-21859
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "dynamodb-examples",
33
"version": "1.0.0",
4-
"author": "Brian Murray <brmur@amazon.com>",
4+
"author": "Brian Murray <brmur@amazon.com> and Corey Pyle <corepyle@amazon.com",
55
"license": "Apache-2.0",
66
"type": "module",
77
"scripts": {
88
"test": "echo 'No test script found.'"
99
},
1010
"dependencies": {
11-
"@aws-sdk/client-dynamodb": "^3.208.0",
12-
"@aws-sdk/lib-dynamodb": "^3.208.0",
11+
"@aws-sdk/client-dynamodb": "^3.210.0",
12+
"@aws-sdk/lib-dynamodb": "^3.210.0",
1313
"ramda": "^0.28.0"
1414
}
1515
}

javascriptv3/example_code/dynamodb/scenarios/dynamodb_basics/src/dynamodb_basics.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const getMovie = async (tableName, title, year) => {
205205
TableName: tableName,
206206
Key: {
207207
title,
208-
year,
208+
year
209209
},
210210
// By default, reads are eventually consistent. "ConsistentRead: true" represents
211211
// a strongly consistent read. This guarantees that the most up-to-date data is returned. It
@@ -308,7 +308,6 @@ const deleteTable = async (tableName) => {
308308
{ TableName: tableName }
309309
);
310310
};
311-
312311
export const runScenario = async ({
313312
tableName,
314313
newMovieName,

javascriptv3/example_code/dynamodb/scenarios/dynamodb_basics/tests/dynamodb_basics.test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ describe("dynamodb_basics#run", () => {
1515

1616
it("should successfully run", async () => {
1717
await runScenario(
18-
"myNewTable",
19-
"myMovieName",
20-
2022,
21-
"This Is the End",
22-
2013,
23-
200,
24-
"A coder cracks code..."
18+
{
19+
tableName: "myNewTable",
20+
newMovieName: "myMovieName",
21+
newMovieYear: 2022,
22+
existingMovieName: "This Is the End",
23+
existingMovieYear: 2013,
24+
newMovieRank: 200,
25+
newMoviePlot: "A coder cracks code...",
26+
moviesPath: "../../../../../../resources/sample_files/movies.json",
27+
}
2528
);
2629
});
2730
});

javascriptv3/example_code/dynamodb/scenarios/dynamodb_basics/tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"author": "Brian Murray <brmur@amazon.com>",
2+
"author": "Brian Murray <brmur@amazon.com> and Corey Pyle <corepyle@amazon.com>",
33
"license": "Apache 2.0",
44
"dependencies": {
55
"@aws-sdk/client-dynamodb": "^3.210.0",

javascriptv3/example_code/dynamodb/scenarios/dynamodb_basics/tests/yarn.lock

Lines changed: 583 additions & 681 deletions
Large diffs are not rendered by default.

javascriptv3/example_code/dynamodb/scenarios/partiQL_basics/libs/ddbClient.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Inputs (replace in code):
1313
// snippet-start:[dynamodb.JavaScript.scenario.partiQL.basics.createclientv3]
1414
// Create the DynamoDB service client module using ES6 syntax.
1515
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
16-
// Set the AWS Region.
17-
export const REGION = "eu-west-1"; // For example, "us-east-1".
16+
import { DEFAULT_REGION } from "../../../../libs/utils/util-aws-sdk.js";
1817
// Create an Amazon DynamoDB service client object.
19-
export const ddbClient = new DynamoDBClient({ region: REGION });
18+
export const ddbClient = new DynamoDBClient({ region: DEFAULT_REGION });
2019
// snippet-end:[dynamodb.JavaScript.scenario.partiQL.basics.createclientv3]

javascriptv3/example_code/dynamodb/scenarios/partiQL_basics/libs/ddbDocClient.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const marshallOptions = {
2020
// Whether to automatically convert empty strings, blobs, and sets to `null`.
2121
convertEmptyValues: false, // false, by default.
2222
// Whether to remove undefined values while marshalling.
23-
removeUndefinedValues: false, // false, by default.
23+
removeUndefinedValues: true, // false, by default.
2424
// Whether to convert typeof object to map attribute.
2525
convertClassInstanceToMap: false, // false, by default.
2626
};
@@ -30,10 +30,11 @@ const unmarshallOptions = {
3030
wrapNumbers: false, // false, by default.
3131
};
3232

33-
const translateConfig = { marshallOptions, unmarshallOptions };
34-
3533
// Create the DynamoDB document client.
36-
const ddbDocClient = DynamoDBDocumentClient.from(ddbClient, translateConfig);
34+
const ddbDocClient = DynamoDBDocumentClient.from(ddbClient, {
35+
marshallOptions,
36+
unmarshallOptions,
37+
});
3738

3839
export { ddbDocClient };
3940
// snippet-end:[dynamodb.JavaScript.scenario.partiQL.createdocclientv3]

0 commit comments

Comments
 (0)