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

energy-db

v0.0.7

Published

a sane and easy to use wrapper around AWS DynamoDB

Downloads

12

Readme

Build Status

energy-db

What is a dynamo without energy???

AWS DynamoDB is great, but it can be very annoying to work with bare hands. Our EnergyDB is a wrapper around DynamoDB, aiming to make it easier to use this managed cloud database, specially for those used to the way MongoDB works.

This still an ALPHA version! Lots of things need to be improved.

Instalation

If you are reading you know how to install a npm module. Just put it in your dependencies list or install it globally if you are one of those people.

How to use it

The basics. EnergyDB needs to use DynamoDB. You have two options: you may pass a DynamoDB instance to EnergyDB or simply provide the credentials and let us instantiate it for you:

var energyDB = require('energy-db');

var settings = {
  region: 'eu-central-1',
  accessKeyId: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
  secretAccessKey: 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
};

energyDB.connect(settings, function(err, db) {
  // energy-db is ready to use!!
});

Once you have the EnergyDb instance, you can get access to tables and perform operations:

db.table('Your-Table-Name', function(err, table) {

  var doc = {
    'key-0': 'value-0',
    'key-1': 12345
  };

  table.putItem(doc[, options], callback);
  // or
  table.query(doc[, options], callback);
  // or
  table.delete(doc[, options], callback);
  // or
  table.update(doc, update[, options], callback);
});

You don't have to bother about converting the object to the DynamoDB strong-typed format. EnergyDB uses DynamoDoc internally to make this convertion for you.

The EnergyTable also supports a number of additional settings, that you can define before performing the queries. For example, you may want to have the information about the consumed read/write capacity or have the old values of a document you are updating. In this case, you can do something like this:

db.table('Your-Table-Name', function(err, table) {

  // The following settings will affect all queries done with this
  // EnergyTable instance.
  table.returnConsumedCapacity().returnOldValues();

  // perform your queries...

  // Another option is to pass an additional 'options' object
  // to the method. This will affect only the query in question.
  table.query(doc, {ConsistentRead: true}, callback);

});

As usual, I suggest you to take a look on the code and the tests, if you want to do something more complex.

Unit tests

This module was TDD'ed and we have good test coverage using mocha+chai. We believe all core functionality is covered, but some error cases are not. We are working to handle these scenarios.

Contributing

Fork the repo, create a branch, do awesome additions and submit a pull-request. Only PR's with tests will be considered.

Releases

  • 0.0.7:

    • Adds additional checks to prevent update/delete errors (removes the double reference to hash and range key in the ConditionExpression)
    • Adds additional check to prevent empty expressions, attribute names and attribute values
  • 0.0.6:

    • Improves code organization
    • Adds the 'options' as an optional argument when performing queries
    • Adds support to return values as plain js object to the update method
    • Some clean up
  • 0.0.5:

    • adds final validation to the query factory to prevent invalid syntax and the use of deprecated operators
  • 0.0.4:

    • adds full-scan functionality
  • 0.0.3:

    • adds support to update and replace operations
    • new structure for unit tests folder
    • better code organization
    • EnergyQuery is now EnergyQueryFactory
    • insert queries now uses EnergyQueryFactory as well
  • 0.0.2:

    • bugfix with new dynamo-doc version
  • 0.0.1

    • Initial alpha release
    • support to query, insert and delete operations