Screwdriver Datastore Dynamodb
interface with dynamodb
Usage
npm install screwdriver-datastore-dynamodb
Initialization
Datastore DynamoDB is an extension of the screwdriver-datastore-base class and implements all of the functions exposed.
Currently the AWS credentials will be loaded from the shared credentials file, or environment variables. Reference to AWS SDK documentation
const DynamoDB = ; const datastore = ;
Define a specific region and credentials to interact with
const DynamoDB = ; const irelandDatastore = region: 'eu-west-1' accessKeyId: 'foo' secretAccessKey: 'bar';
get
Obtain a single record given an id. If the record does not exist, it will return null
.
Parameter | Type | Description |
---|---|---|
config | Object | Each of its properties defines your get operation |
config.table | String | The datastore table name |
config.params | Object | Each of its properties defines the get parameters |
config.params.id | String | The ID of the item to fetch from the datastore |
Example
const DynamoDB = ;const datastore = ; // successful get operationreturn datastore; // get operation on a non-existing entryreturn datastore;
save
Save a record in the datastore. Returns saved data.
Parameter | Type | Description |
---|---|---|
config | Object | Each of its properties defines your get operation |
config.table | String | The datastore table name |
config.params | Object | Each of its properties defines the get parameters |
config.params.id | String | The ID that the data is associated with |
config.params.data | Object | The data that will be saved in the datastore |
Example
const DynamoDB = ;const datastore = ; // successful save operationreturn datastore;
update
Update a record in the datastore. Returns null
if the record does not exist
Parameter | Type | Description |
---|---|---|
config | Object | Each of its properties defines your get operation |
config.table | String | The datastore table name |
config.params | Object | Each of its properties defines the get parameters |
config.params.id | String | The ID that the data is associated with |
config.params.data | Object | The data to be updated in the datastore |
Example
const DynamoDB = ;const datastore = ; // successful update operationreturn datastore; // update operation on a non-existing entryreturn datastore;
scan
Scan for records in the datastore. Returns []
if the table is empty. Returns error if the table does not exist.
Parameter | Type | Description |
---|---|---|
config | Object | Each of its properties defines your get operation |
config.table | String | The datastore table name |
config.params | Object | Query to filter on |
Example
const DynamoDB = ;const datastore = ; // successful scan operationreturn datastore;
Testing
npm test
License
Code licensed under the BSD 3-Clause license. See LICENSE file for terms.