Socket
Socket
Sign inDemoInstall

repository-dynamodb

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    repository-dynamodb

A generic repository pattern for node.js apps accessing dynamodb


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Readme

Source

repository.dynamodb

A generic repository pattern for dynamodb written for node.js

Usage

Construct the Repository using the aws region, dynamoDb table name, name of the id key and optionally name of the range key.

With both id and range


let Repository = require('repository-dynamodb');
let repository = new Repository('eu-west-1', 'tableone', 'id', 'range');

With just id


let Repository = require('repository-dynamodb');
let repository= new Repository('eu-west-1', 'tableone', 'id');

API

repository.findBy(id, range, callback);
repository.findBy(id, callback);
repository.addOrReplace(item, callback);
repository.removeBy(id, range, callback);
repository.removeBy(id, callback);

Extending

If you want to provide an additional function specific to your repository, the dynamodb docClient is provided:

repository.listCurrentArticles = function scanDynamoDbForCurrentArticles(callback) {
    let params = {
        TableName: 'news',
        ExpressionAttributeNames: {
            "#D": "date",
            "#E": "expiration"
        },
        ExpressionAttributeValues: {
            ":NOW": new Date().toISOString()
        },
        FilterExpression: ':NOW between #D and #E'
    };
    this.docClient.scan(params, callback);
};

FAQs

Last updated on 26 Jul 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc