Socket
Book a DemoInstallSign in
Socket

dynazord

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynazord

DynamoDB NodeJS ORM

latest
Source
npmnpm
Version
1.5.2
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Dynazord logo

NPM CI Coverage

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.

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

$ 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-local
    docker run --rm -d --name dynamodb -p 8000:8000 amazon/dynamodb-local
    
    • Please take note of the differences between the production AWS DynamoDB platform & local Docker container.

Any questions or suggestions please open an issue.

Keywords

amazon

FAQs

Package last updated on 25 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts