Socket
Socket
Sign inDemoInstall

eudynamys

Package Overview
Dependencies
42
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eudynamys

A simple query builder for DynamoDB


Version published
Maintainers
3
Created

Readme

Source

eudynamys

license npm version CircleCI codecov NSP Status

NPM

Yet another simple query builder for DynamoDB. Give it a try!

Install

npm install --save eudynamys

eudynamys requires Node 6+.

Usage

Instantiate the client

const AWS = require('aws-sdk');
const dbDocClient = new AWS.DynamoDB.DocumentClient();
const QueryBuilder = require('eudynamys');
const qb = new QueryBuilder(dbDocClient);

Debug

You can pass a debug function as 2nd parameter of QueryBuilder constructor. It will displays the parameters passed to DynamoDB document client. Use either console.log or a custom logger.

const qb = new QueryBuilder(dbDocClient, console.log);

API

Filters and methods return this

  • table(tableName), from(tableName) Select a table
  • index(indexName) Select an index
  • item(object = {}) Define an item to put
  • select(attributeName = '') Attributes to fetch
  • exclusiveStartKey(key) In order to loop
  • scanIndexForward(value) To define the order for traversal index
  • limit(number) Maximum number of items
  • count() Count
  • where(keyAttributeName = '') Where
  • filter(attributeName = '') Filter
  • if(attributeName = '') If
  • match(joiSchema = {}) Match a Joi schema
  • equals(...args), eq(...args) Equals
  • ne(...args) Not equals
  • lte(...args) Lower than or equal
  • lt(...args) Lower than
  • gte(...args) Greater than or equal
  • gt(...args) Greater than
  • between(...args) Between
  • in(...args) In
  • and(...args) And
  • or(...args) Or
  • not(...args) Not
  • op(...args) Open parenthesis
  • cp(...args) Close parenthesis

Actions, return a Promise resolved with DynamoDB response.

  • put()
  • update()
  • query()
  • scan()
  • get()

Example

qb.select(['uuid', 'title', 'createdAt'])
  .from('sample')
  .where('key').eq('8e7d307b-4e1b-4f26-984b-dfc2b35bdbbc')
  .filter('published').eq(false)
  .and().begins('type', 'Ty')
  .and('createdAt').gt(1457278812)
  .query();

Lint

npm run lint

Test

Requires node 8+. Will install a DynamoDB local server using dynamodb-localhost, create and seed a table, and validate results.

npm run test

Keywords

FAQs

Last updated on 07 Oct 2018

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