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 🙏

© 2026 – Pkg Stats / Ryan Hefner

altdynamo

v0.2.1

Published

> A helper module to handle AWS.DynamoDB.DocumentClient.

Readme

altdynamo NPM version

A helper module to handle AWS.DynamoDB.DocumentClient.

Install

Install with npm:

$ npm install --save altdynamo

Usage

Put item to table

const {ParamsBuilder,DocClient} = require('altdynamo');
const aws = require('aws-sdk');
const doc = new aws.DynamoDB.DocumentClient({
    accessKeyId: 'my-key',
    secretAccessKey: 'my-secret',
    region: 'my-region',
    apiVersion: '2012-08-10'
});


// #1. use when creating only params with ParamsBuilder
const pb = new ParamsBuilder();
const params = pb.table('test')
    .item({
        testKey: 'foo',
        itemType: 'bar',
        created: Date.now()
    }).params;
    
doc.put(params).promise()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });


// #2. use when executing together with DocClient
const docClient = new DocClient(doc);
docClient.table('test')
    .item({
        testKey: 'foo',
        itemType: 'bar',
        created: Date.now()
    })
    .executePut()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });

Get item from table

const {ParamsBuilder,DocClient} = require('altdynamo');
const aws = require('aws-sdk');
const doc = new aws.DynamoDB.DocumentClient({
    accessKeyId: 'my-key',
    secretAccessKey: 'my-secret',
    region: 'my-region',
    apiVersion: '2012-08-10'
});


// #1. use when creating only params with ParamsBuilder
const pb = new ParamsBuilder();
const params = pb.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    }).params;
    
doc.get(params).promise()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });


// #2. use when executing together with DocClient
const docClient = new DocClient(doc);
docClient.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    })
    .executeGet()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });

Update item to table

const {ParamsBuilder,DocClient} = require('altdynamo');
const aws = require('aws-sdk');
const doc = new aws.DynamoDB.DocumentClient({
    accessKeyId: 'my-key',
    secretAccessKey: 'my-secret',
    region: 'my-region',
    apiVersion: '2012-08-10'
});


// #1. use when creating only params with ParamsBuilder
const pb = new ParamsBuilder();
const params = pb.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    })
    .update({
        updated: Date.now()
    }).params;
    
doc.update(params).promise()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });


// #2. use when executing together with DocClient
const docClient = new DocClient(doc);
docClient.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    })
    .update({
        updated: Date.now()
    })
    .executeUpdate()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });

Query items from table

const {ParamsBuilder,DocClient} = require('altdynamo');
const aws = require('aws-sdk');
const doc = new aws.DynamoDB.DocumentClient({
    accessKeyId: 'my-key',
    secretAccessKey: 'my-secret',
    region: 'my-region',
    apiVersion: '2012-08-10'
});


// #1. use when creating only params with ParamsBuilder
const pb = new ParamsBuilder();
const params = pb.table('test')
    .eq('testKey','foo')
    .toKeyCondition().params;
    
doc.query(params).promise()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });


// #2. use when executing together with DocClient
const docClient = new DocClient(doc);
docClient.table('test')
    .eq('testKey','foo')
    .toKeyCondition()
    .executeQuery()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });

Delete item to table

const {ParamsBuilder,DocClient} = require('altdynamo');
const aws = require('aws-sdk');
const doc = new aws.DynamoDB.DocumentClient({
    accessKeyId: 'my-key',
    secretAccessKey: 'my-secret',
    region: 'my-region',
    apiVersion: '2012-08-10'
});


// #1. use when creating only params with ParamsBuilder
const pb = new ParamsBuilder();
const params = pb.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    }).params;
    
doc.delete(params).promise()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });


// #2. use when executing together with DocClient
const docClient = new DocClient(doc);
docClient.table('test')
    .key({
        testKey: 'foo',
        itemType: 'bar'
    })
    .executeDelete()
    .then(data=>{
        console.log(data);
    })
    .catch(err=> {
        console.log(err);
    });

API Reference

class ParamsBuilder

constructor() ⇒ ParamsBuilder
to initiate an instance of the ParamsBuilder.

clear() ⇒ ParamsBuilder
to initialize all values of .params except .params.TableName.

table(name) ⇒ ParamsBuilder
to set .params.TableName by the name argument.

addExpressionToken(txt) ⇒ ParamsBuilder
to add txt argument to .expressionTokens[]. (It is forbidden to use reserved words or direct values in the Expression of DocumentClient. Therefore, it is recommended to add tokens through other methods that automatically convert name and value to ExpressionAttributeName and ExpressionAttributeValue rather than adding the token directly to this method.)

toCondition() ⇒ ParamsBuilder
to set .params.ConditionExpression by joining all tokens of .expressionTokens[]. and all tokens of .expressionTokens[] are cleared.

toKeyCondition() ⇒ ParamsBuilder
to set .params.KeyConditionExpression by joining all tokens of .expressionTokens[]. and all tokens of .expressionTokens[] are cleared.

toFilter() ⇒ ParamsBuilder
to set .params.FilterExpression by joining all tokens of .expressionTokens[]. and all tokens of .expressionTokens[] are cleared.

and() ⇒ ParamsBuilder
to add 'AND' token to .expressionTokens[].

or() ⇒ ParamsBuilder
to add 'OR' token to .expressionTokens[].

not() ⇒ ParamsBuilder
to add 'NOT' token to .expressionTokens[].

open() ⇒ ParamsBuilder
to add '(' token to .expressionTokens[].

close() ⇒ ParamsBuilder
to add ')' token to .expressionTokens[].

eq(name,value) ⇒ ParamsBuilder
to add ':name = #value' token to .expressionTokens[].

ne(name,value) ⇒ ParamsBuilder
to add ':name <> #value' token to .expressionTokens[].

lt(name,value) ⇒ ParamsBuilder
to add ':name < #value' token to .expressionTokens[].

le(name,value) ⇒ ParamsBuilder
to add ':name <= #value' token to .expressionTokens[].

gt(name,value) ⇒ ParamsBuilder
to add ':name > #value' token to .expressionTokens[].

ge(name,value) ⇒ ParamsBuilder
to add ':name >= #value' token to .expressionTokens[].

begins(name,value) ⇒ ParamsBuilder
to add 'BEGINS_WITH (:name, #value)' token to .expressionTokens[].

notBegins(name,value) ⇒ ParamsBuilder
to add 'NOT BEGINS_WITH (:name, #value)' token to .expressionTokens[].

between(name,value1,value2) ⇒ ParamsBuilder
to add ':name BETWEEN #value1 AND #value2' token to .expressionTokens[].

notBetween(name,value1,value2) ⇒ ParamsBuilder
to add 'NOT :name BETWEEN #value1 AND #value2' token to .expressionTokens[].

exists(name) ⇒ ParamsBuilder
to add 'ATTRIBUTE_EXISTS (:name)' token to .expressionTokens[].

notExists(name) ⇒ ParamsBuilder
to add 'ATTRIBUTE_NOT_EXISTS (:name)' token to .expressionTokens[].

type(name,value) ⇒ ParamsBuilder
to add 'ATTRIBUTE_TYPE (:name,#value)' token to .expressionTokens[].

notType(name,value) ⇒ ParamsBuilder
to add 'NOT ATTRIBUTE_TYPE (:name,#value)' token to .expressionTokens[].

contains(name,value) ⇒ ParamsBuilder
to add 'CONTAINS (:name,#value)' token to .expressionTokens[].

notContains(name,value) ⇒ ParamsBuilder
to add 'NOT CONTAINS (:name,#value)' token to .expressionTokens[].

in(name,[value1,value2,...]) ⇒ ParamsBuilder
to add ':name IN (#value1,#value2,...)' token to .expressionTokens[].

notIn(name,[value1,value2,...]) ⇒ ParamsBuilder
to add 'NOT :name IN (#value1,#value2,...)' token to .expressionTokens[].

size(name,operator,value) ⇒ ParamsBuilder
to add 'SIZE (:name) operator #value' token to .expressionTokens[]. (operator should be one of '=','<>','<','<=','>', '>=')

index(name) ⇒ ParamsBuilder
to set .params.IndexName by the name argument.

key(obj) ⇒ ParamsBuilder
to set .params.Key by the obj argument.

item(obj) ⇒ ParamsBuilder
to set .params.Item by the obj argument.

update({name1:value1,name2:value2,...}, action='SET') ⇒ ParamsBuilder
to set .params.UpdateExpression by the obj argument converted to 'action :name1 = #value1, :name2 = #value2,...'. (action should be one of 'SET','ADD','REMOVE','DELETE'. 'SET' is default)

limit(num) ⇒ ParamsBuilder
to set .params.Limit by the num argument.

projection('name1,name2,...') ⇒ ParamsBuilder
to set .params.ProjectionExpression by the commaed names argument converted to ':name1, :name2,...'.

consumedCapacity(which) ⇒ ParamsBuilder
to set .params.ReturnComsumedCapacity by the which argument. (which should be one of 'TOTAL','INDEXES','NOT')

returnValues(which) ⇒ ParamsBuilder
to set .params.ReturnValues by the which argument. (which should be one of 'ALL_OLD','ALL_NEW','UPDATED_OLD','UPDATED_NEW')

class DocClient extends ParamsBuilder

constructor(doc) ⇒ DocClient
to initiate an instance of the DocClient. A aws.DynamoDB.DocumentClient instance is required.

executePut() ⇒ Promise
to execute the put method of the DocumentClient with .params of this. It will return a Promise when called with no argument.

executePut(callback) ⇒ DocClient
to execute the put method of the DocumentClient with .params of this. It will return the DocClient when called with a callback function.

executeGet() ⇒ Promise
to execute the get method of the DocumentClient with .params of this. It will return a Promise when called with no argument.

executeGet(callback) ⇒ DocClient
to execute the get method of the DocumentClient with .params of this. It will return the DocClient when called with a callback function.

executeUpdate() ⇒ Promise
to execute the update method of the DocumentClient with .params of this. It will return a Promise when called with no argument.

executeUpdate(callback) ⇒ DocClient
to execute the update method of the DocumentClient with .params of this. It will return the DocClient when called with a callback function.

executeDelete() ⇒ Promise
to execute the delete method of the DocumentClient with .params of this. It will return a Promise when called with no argument.

executeDelete(callback) ⇒ DocClient
to execute the delete method of the DocumentClient with .params of this. It will return the DocClient when called with a callback function.

executeQuery() ⇒ Promise
to execute the query method of the DocumentClient with .params of this. It will return a Promise when called with no argument.

executeQuery(callback) ⇒ DocClient
to execute the query method of the DocumentClient with .params of this. It will return the DocClient when called with a callback function.

License

Copyright © 2018, Seunghwan Noh. Released under the MIT License.

This is a module made more easily inspired by dynomo-node. The basic idea owes to @abdullahzn who created the dynamo-node.