Amazon DynamoDB local setup
npm install aws-dbDynamoDB is a highly scalable noSQL database system available on Amazon
Web Services (AWS). You can read more about it from its
official site.
Prerequisite: Java version 6 or above must be available on the system
> $ npm install -g aws-db
Once the aws-db package is installed. You should be able to start the
dynamodb database server from command line.
> $ aws-db
$ aws-db 8080 > $ aws-db 8080 data
Runs dynamodb in port 8080 with persistent storage in a folder named data
in the current directory.
> $ npm install --save-dev aws-db
or
> $ yarn add --dev aws-db
Once installed on your package, you could start the dynamodb server by importing
the library
``javascript
// Your test file
const dynamoDB = require('aws-db');
// Start the dynamoDB server
const shutdownDynamoDB = dynamoDB();
...
...
// Once you are done, you can (should) shutdown the server at the end
shutdownDynamoDB();
`
> dbPath
The location where the database server creates the database files. If this
value is omitted (or null), in-memory database is used which is not persistent.
> delayTransitionStatuses
The local database server are extremely fast and don't take time for most of
the operations, which is not the case when you are using the service online on
AWS. To simulate a similar environment, you could enable a delay on the local
database. Just pass true if you want to enable delays on certain functions.
Please check the AWS documentation
for more information on these parameters.
The sharedDb` flag is always set.
The function returns a function that should be used to shutdown the server
at the end of the execution of your tests.