Skip to content

Repository files navigation

dynam

DynamoDB Wrapper

Install

yarn add dynam

Or with NPM

npm i -S dynam

Initialize

constdynam=require('dynam');// Read credentials from ~/.aws/credentials or envirnmentconstdb=newdynam();// Change profileconstdb=newdynam({profile: 'connor'});// Change regionconstdb=newdynam({region: 'us-west-2'});// Manually inputconstdb=newdynam({accessKeyId: '...',secretAccessKey: '...',region: 'us-west-2',});

Query

dynam.query(TableName, Params) => Promise

db.query('logs',{id: 'B1x6Omk23z'}).then(function(results){console.log(results);});

Outputs:

[{id: 'B1x6Omk23z',time: 1524524731,
...
}]

Scan

dynam.scan(TableName, Params) => Promise

db.query('logs',{type: 'event'}).then(function(results){console.log(results);});

Outputs:

[{id: 'B1x6Omk23z',time: 1524524731,type: 'event'},{id: 'ByLv7y22G',time: 1524524882,type: 'event'}]

Conditions

Both query and scans accept conditions other than equals to.

SymbolCondition
=Equal To
>Greater Than
>=Greater Than / Equal To
<Less Than
=<Less Than / Equal To
bwBegins With (Strings)

Example:

db.scan('logs',{time'>'+Date.now()+(1000*60)// Past minute});

About

DynamoDB Wrapper

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages