Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alternator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alternator

A simplified API to DynamoDB

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Alternator

A simplified API to DynamoDB

State - Experimental

DynamoDB is hard to figure out and the state of the docs really doesn't help. Use this module at your own risk!

Usage

var alternator = require('alternator');

// create a db wrapper
var db = alternator(

        // AWS config stuff
        {
            endpoint: new AWS.Endpoint('http://localhost:8000'),
            accessKeyId: "myKeyId",
            secretAccessKey: "secretKey",
            region: "us-east-1"
        },

        // An array of configs for tables you expect to exist and that you want to work with.
        // Tables that don't exist on the DB will be created.
        // Existing tables will be compared, and will throw if they do not match.
        [
            {
                name: 'users',
                key: {
                    name: 'hash', // A hash is required
                    version: 'range' // A range is optional
                },
                attributes: {
                    name: 'string',
                    version: 'number'
                }
            }
        ]

    );

// Create a user
db.table('users').create({
    name: 'bob',
    version: 0
}, callback); // -> righto : item

// Get a user
db.table('users').get({
    key: {
        name: 'bob',
        version: 0
    }
}, callback); // -> righto : item

// Get multiple users by index
db.table('users').findAll({
    key: {
        name: 'bob'
    }
}, callback); // -> righto : [item]

// Search multiple users
db.table('users').scan({
    expression: 'foo = :foo',
    attributeValues: {
        ':foo': 'bar'
    }
}, callback); // -> righto : [item]

// Update a user
db.table('users').update({
    key: {
        name: 'bob',
        version: 0
    }
    item: {
        version: 1
    }
}, callback); // -> righto : item

// Update a user with an expression
db.table('users').update({
    key: {
        name: 'bob',
        version: 0
    }
    expression: 'ADD version :one',
    attributeValues: {
        ':one': 1
    }
}, callback); // -> righto : item

// Remove a user
db.table('users').remove({
    key: {
        name: 'bob',
        version: 0
    }
}, callback); // -> righto : nothing

FAQs

Package last updated on 09 Jul 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc