README

DynamoDB NodeJS ORM, inspired by similar ORMs like Mongoose & Sequelize.
const dynazord = require('dynazord');
const users = dynazord.createModel({
tableName: 'dynazord-test-users',
keySchema: {
hash: 'email',
},
properties: {
email: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
avatar: {
type: String,
},
role: {
type: String,
enum: [ 'ADMIN', 'MODERATOR', 'EDITOR', 'USER' ],
default: () => 'USER',
},
},
});
const user = await users.create({
email: 'jdrydn@github.io',
name: 'James D',
avatar: 'https://github.com/jdrydn.png',
});
console.log(user);
// { email: 'jdrydn@github.io',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'USER' }
const user = await users.get({ email: 'jdrydn@github.io' });
console.log(user);
// { email: 'jdrydn@github.io',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'USER' }
const user = await users.update({ role: 'EDITOR' }, { email: 'jdrydn@github.io' });
console.log(user);
// { email: 'jdrydn@github.io',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'EDITOR' }
const user = await users.delete({ email: 'jdrydn@github.io' });
console.log(user);
// true
This library is designed to simplify interaction with DynamoDB, offering more traditional CRUD methods instead of learning DynamoDB's getItem/putItem methods. You can also write functions to validate properties on objects & add other hooks to transform data to suit your needs.
Installation
$ npm install --save dynazord
Documentation
Development
- Documentation is stored in Git, alongside code, therefore as code changes so should the documentation!
- All major work should be in feature branches, include tests & finish with a PR into
master. - To run tests, fire up
amazon/dynamodb-localdocker run --rm -d --name dynamodb -p 8000:8000 amazon/dynamodb-local- If you've not read through them, take note of the differences between the production AWS DynamoDB platform & local Docker container.
Any questions or suggestions please open an issue.