Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/someimportantcompany/dynazord
DynamoDB NodeJS ORM
https://github.com/someimportantcompany/dynazord
amazon aws dynamo dynamodb model nosql schema
Last synced: about 2 months ago
JSON representation
DynamoDB NodeJS ORM
- Host: GitHub
- URL: https://github.com/someimportantcompany/dynazord
- Owner: someimportantcompany
- License: mit
- Created: 2020-12-22T13:44:51.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-03T15:48:23.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T10:17:29.395Z (3 months ago)
- Topics: amazon, aws, dynamo, dynamodb, model, nosql, schema
- Language: JavaScript
- Homepage:
- Size: 734 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Dynazord logo](./docs/logo.png)
[![NPM](https://badge.fury.io/js/dynazord.svg)](https://npm.im/dynazord)
[![CI](https://github.com/someimportantcompany/dynazord/workflows/Test/badge.svg?branch=master)](https://github.com/someimportantcompany/dynazord/actions?query=branch%3Amaster)
[![Coverage](https://coveralls.io/repos/github/someimportantcompany/dynazord/badge.svg)](https://coveralls.io/github/someimportantcompany/dynazord)[DynamoDB](https://aws.amazon.com/dynamodb) [NodeJS](https://nodejs.org) [ORM](https://en.wikipedia.org/wiki/Object–relational_mapping), inspired by similar ORMs like [Mongoose](https://mongoosejs.com) & [Sequelize](https://sequelize.org).
```js
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: '[email protected]',
name: 'James D',
avatar: 'https://github.com/jdrydn.png',
});
console.log(user);
// { email: '[email protected]',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'USER' }const user = await users.get({ email: '[email protected]' });
console.log(user);
// { email: '[email protected]',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'USER' }const user = await users.update({ role: 'EDITOR' }, { email: '[email protected]' });
console.log(user);
// { email: '[email protected]',
// name: 'James D',
// avatar: 'https://github.com/jdrydn.png'
// role: 'EDITOR' }const user = await users.delete({ email: '[email protected]' });
console.log(user);
// true
```This library is designed to simplify interaction with DynamoDB, offering more traditional CRUD methods instead of learning DynamoDB's [`getItem`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#getItem-property)/[`putItem`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property) methods. You can also write functions to validate properties on objects & add other hooks to transform data to suit your needs.
### Features
- Create schemas for items in DynamoDB, with validation & hooks to transform data on read & write.
- Read/write methods supporting create, read, update, delete & upsert.
- Bulk read/write methods supporting create, read, update, delete & upsert.
- Transactional read/write methods supporting create, read, update, delete & upsert.
- Query & scan support, following DynamoDB principles.
- "OneTable" support, where models can share the same DynamoDB table underneath.## Installation
```bash
$ npm install --save dynazord
```## Documentation
- [Getting Started](./docs/1-Getting-Started.md)
- [Writing Models](./docs/2-Writing-Models.md)
- [Using Models](./docs/3-Using-Models.md)
- [Examples](./examples/)## 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-local`](https://hub.docker.com/r/amazon/dynamodb-local)
```
docker run --rm -d --name dynamodb -p 8000:8000 amazon/dynamodb-local
```
- Please take note of [the differences](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.UsageNotes.html#DynamoDBLocal.Differences) between the production AWS DynamoDB platform & local Docker container.---
Any questions or suggestions please [open an issue](https://github.com/someimportantcompany/dynazord/issues).