Skip to content

Commit

Permalink
Merge pull request #513 from busticated/update-dynamodb-local-samples
Browse files Browse the repository at this point in the history
Update dynamodb local samples
  • Loading branch information
Michael O'Brien committed Dec 4, 2023
2 parents 028a644 + b767d81 commit f5349a4
Show file tree
Hide file tree
Showing 12 changed files with 5,498 additions and 3,073 deletions.
4 changes: 3 additions & 1 deletion samples/crud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ It has the following features:
* AWS V3 SDK
* Starts own DynamoDB instance on port 4567


## Read the Code

* [CRUD Source](https://github.com/sensedeep/dynamodb-onetable/tree/main/samples/crud/src/index.js)
* [CRUD Source](/samples/crud/src/index.js)


## Building
Expand All @@ -35,3 +36,4 @@ make run
```
code .
```

2,721 changes: 1,669 additions & 1,052 deletions samples/crud/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dynamodb-onetable": "^2"
},
"devDependencies": {
"dynamo-db-local": "^4.0.2",
"dynamo-db-local": "^7.1.0",
"typescript": "^4.3.4"
}
}
6 changes: 5 additions & 1 deletion samples/crud/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
This sample runs its own local dynamodb instance on port 4567
*/

// ensure required env vars are set
process.env['AWS_ACCESS_KEY_ID'] = 'dynamodb'
process.env['AWS_SECRET_ACCESS_KEY'] = 'doesntmatter'

import {DynamoDBClient} from '@aws-sdk/client-dynamodb'
import DynamoDbLocal from 'dynamo-db-local'

Expand Down Expand Up @@ -62,7 +66,7 @@ let dynamodb = null
async function start() {
// Start the dynamodb instance and then short wait for it to open a listening port.
dynamodb = DynamoDbLocal.spawn({port: PORT})
await delay(1000)
await delay(2000) // increase upon `ECONNREFUSED` error
}

async function stop() {
Expand Down
2 changes: 1 addition & 1 deletion samples/overview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It has the following features:

## Read the Code

* [Overview Source](https://github.com/sensedeep/dynamodb-onetable/tree/main/samples/overview/src/index.js)
* [Overview Source](/samples/overview/src/index.js)

## Building

Expand Down
3,091 changes: 2,131 additions & 960 deletions samples/overview/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/overview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dynamodb-onetable": "^2"
},
"devDependencies": {
"dynamo-db-local": "^4.0.2",
"dynamo-db-local": "^7.1.0",
"typescript": "^4.3.4"
}
}
12 changes: 11 additions & 1 deletion samples/overview/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
This sample runs its own local dynamodb instance on port 4567.
*/

// ensure required env vars are set
process.env['AWS_ACCESS_KEY_ID'] = 'dynamodb'
process.env['AWS_SECRET_ACCESS_KEY'] = 'doesntmatter'

import {DynamoDBClient} from '@aws-sdk/client-dynamodb'
import DynamoDbLocal from 'dynamo-db-local'

Expand Down Expand Up @@ -52,7 +56,7 @@ let dynamodb = null
async function start() {
// Start the dynamodb instance and then short wait for it to open a listening port.
dynamodb = DynamoDbLocal.spawn({port: PORT})
await delay(1000)
await delay(2000) // increase upon `ECONNREFUSED` error
}

async function stop() {
Expand Down Expand Up @@ -207,6 +211,12 @@ async function test() {
users = await User.find({}, {index: 'gs1'})
invoices = await Invoice.find({}, {index: 'gs1'})

/*
Print DB contents
*/

console.dir(await table.scanItems({}))

/*
Cleanup
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/packed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It has the following features:

## Read the Code

* [Packed Attributes Source](https://github.com/sensedeep/dynamodb-onetable/tree/main/samples/packed/src/index.js)
* [Packed Attributes Source](/samples/packed/src/index.js)

## Requirements

Expand Down
2,721 changes: 1,669 additions & 1,052 deletions samples/packed/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/packed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dynamodb-onetable": "^2"
},
"devDependencies": {
"dynamo-db-local": "^4.0.2",
"dynamo-db-local": "^7.1.0",
"typescript": "^4.1.3"
}
}
6 changes: 5 additions & 1 deletion samples/packed/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
This works around that limitation.
*/

// ensure required env vars are set
process.env['AWS_ACCESS_KEY_ID'] = 'dynamodb'
process.env['AWS_SECRET_ACCESS_KEY'] = 'doesntmatter'

import {DynamoDBClient} from '@aws-sdk/client-dynamodb'
import DynamoDbLocal from 'dynamo-db-local'

Expand Down Expand Up @@ -66,7 +70,7 @@ let dynamodb = null
async function start() {
// Start the dynamodb instance and then short wait for it to open a listening port.
dynamodb = DynamoDbLocal.spawn({port: PORT})
await delay(1000)
await delay(2000) // increase upon `ECONNREFUSED` error
}

async function stop() {
Expand Down

0 comments on commit f5349a4

Please sign in to comment.