simple-dyno
Easy to use, minimalistic wrapper for AWS DynamoDB
Installation
$ npm install simple-dyno
Features
- Easy way to create a model, keeping your code consistent and saving it to DynamoDB
- Serializers to format your (json) response
- Validation based on Joi
- Encryption using bcrypt for your passwords
- Local DynamoDB for testing purposes
Methods
To create a new entry, and options can include {skipValidation: true}
:
Model.create(attributes, options)
To get an entry or multiple entries:
Model.get(keyValues)
To update an entry, and options can include {skipValidation: true}
:
Model.update(keyValues, attributes, options)
To delete an entry:
Model.destroy(keyValues)
To perform a scan operation (not recommended):
Model.find(attributes)
To query using a secondary index:
Model.query(indexName, attributes)
To serialize the response attributes:
Model.serialize(response, options)
To run a local DynamoDB (which runs on Java), by default runs in memory but you can also store on disk using {inMemory: false}
as options:
SimpleDyno.local(options)
To set the config, which you can pass the following options {accessKeyId: '', secretAccessKey: '', region: ''}
:
SimpleDyno.config(options)
Example (in this case the config is set by default by AWS and assumes tables are already created)
// Import deps;; // Add your own methods { return objfirstName+objlastName; } // Create model instancevar User = table: 'users' hashKey: 'email' serializers: default: 'email' scary: 'access_token' 'password' schema: email: Joi access_token: Joi password: format: Joi encrypt: true ; var userObj = Userreturn User;
Example of running the local environment
// Import deps; // Start a local DynamoDB SimpleDyno; // Create accociated tables for the following model(s)SimpleDyno;
Todo
- Fix CI by allowing Java to run on Travis
- Migrations
- Better docs (explain how AWS works)
How to contribute
Please create a pull request, make sure to include and update the tests and that they're working. And don't forget to build the minified version (with babel) with make simple-dyno.js
.
Running tests
Use make test
to do a test run using Mocha.
Legal stuff (MIT License)
Copyright (c) 2016 Awkward.
Distributed under MIT license.