npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fluent-dynamo

v1.4.0

Published

A fluent interface for Amazon DynamoDB in Node.js

Downloads

10

Readme

fluent-dynamo

A fluent interface for Amazon DynamoDB in Node.js

npm version build status code climate test coverage github issues dependencies dev dependencies downloads

dynamo.createTable(table)

Creates a table with the specified configuration (see CreateTable). Below is an example of creating a table with a global secondary index and a local secondary index.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.createTable('Thread')
  .withHashKey('ForumName').asString()
  .withRangeKey('Subject').asString()
  .withReadCapacity(5)
  .withWriteCapacity(5)
  .withGlobalSecondaryIndex('PostCountIndex')
    .withHashKey('ForumName').asString()
    .withRangeKey('PostCount').asNumber()
    .withReadCapacity(1)
    .withWriteCapacity(1)
    .withAllAttributesProjection()
  .withLocalSecondaryIndex('LastPostIndex')
    .withHashKey('ForumName').asString()
    .withRangeKey('LastPostDateTime').asString()
    .withKeysOnlyProjection()
  .then(function() {
    // the table was created
  })
  .catch(function(reason) {
    // an error occurred
  });

dynamo.putItem(table)

Creates a new item or replaces an existing item in the table (see PutItem). Below is an example of inserting an item with attribute conditions.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.putItem('Thread')
  .withAttribute('ForumName').asString('Amazon')
  .withAttribute('Subject').asString('DynamoDB')
  .withAttribute('LastPostDateTime').asString('201303190422')
  .withAttribute('PostCount').asNumber(100)
  .withCondition('ForumName').isNotEqualToString('Amazon')
  .withCondition('Subject').isNotEqualToString('DynamoDB');
  .then(function() {
    // the item was inserted into the table
  })
  .catch(function(reason) {
    // an error occurred
  });

dynamo.deleteItem(table)

Deletes an item in the table (see DeleteItem). Below is an example of deleting an item with a specific hash key and range key.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.deleteItem('Thread')
  .withHashKey('ForumName').asString('Amazon')
  .withRangeKey('Subject').asString('DynamoDB')
  .then(function() {
    // the item was deleted from the table
  })
  .catch(function(reason) {
    // an error occurred
  });

dynamo.query(table)

Searches for items in the table (see Query). Below is an example of querying for an item by a specific hash key.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.query('Thread')
  .withConsistentRead()
  .withCondition('ForumName').isEqualToString('Amazon')
  .then(function(items) {
    // the items were found and are in the following format:

    // items = [
    //   {
    //     ForumName: 'Amazon',
    //     Subject: 'DynamoDB',
    //     PostCount: 100
    //   },
    //   {
    //     ForumName: 'Amazon',
    //     Subject: 'Elastic Beanstalk',
    //     PostCount: 50
    //   }
    // ];
  })
  .catch(function(reason) {
    // an error occurred
  });

dynamo.deleteTable(table)

Deletes the table (see DeleteTable). Below is an example of deleting a table by name.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.deleteTable('Thread')
  .then(function() {
    // the table was deleted
  })
  .catch(function(reason) {
    // an error occurred
  });

dynamo.updateItem(table)

Updates and item in a table (see UpdateItem). Below is an example of updating an attribute in a table.

var fluent = require('fluent-dynamo');

var dynamo = fluent()
  .withAccessKeyId('YOUR_ACCESS_KEY_ID')
  .withRegion('YOUR_REGION')
  .withSecretAccessKey('YOUR_SECRET_ACCESS_KEY');

dynamo.updateItem('Thread')
  .withHashKey('ForumName').asString('Amazon')
  .withRangeKey('Subject').asString('DynamoDB')
  .withSetExpression('LastPostedBy').asString('[email protected]')
  .withRemoveExpression('Archived')
  .withCondition('LastPostedBy').isEqualToString('[email protected]')
  .withAllNewReturnValues();
  .then(function() {
    // the "LastPostedBy" attribute is now "[email protected]"
    // and the "Archived" attribute is removed
  })
  .catch(function(reason) {
    // an error occurred
  });