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

dinamo

v2.0.1

Published

Amazon DynamoDB utilities for Node.js

Downloads

55

Readme

Dinamo

Amazon Dynamo (Amazon DynamoDB) opinionated utilities for Node.js.

NPM version

npm

Getting started

First install the library:

npm i dinamo @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb

Note that @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb are peer dependencies for this library, so instead of bundling it with the package you MUST install it separately.

Then create an instance in your code:

import Dinamo from 'dinamo'

const dinamo = new Dinamo({ tableName: 'my-table' })

If you are using DynamoDB in a Docker container you can pass the endpoint as a parameter:

const dinamo = new Dinamo({
  endpoint: 'http://localhost:8000',
  tableName: 'my-table',
})

You can also configure the AWS SDK client logger:

const dinamo = new Dinamo({
  logger: console,
  tableName: 'my-table',
})

Usage

batchGet

Gets items in batch.

await dinamo.batchGet({ keys: [{ id: 'a' }, { id: 'b' }, { id: 'c' }] })

decrement

Decrements an item. Step is optional.

await dinamo.decrement({ key: { id: 'a' }, field: 'count', step: 1 })

delete

Soft deletes an item, i.e., adds a flag deletedAt with the timestamp of deletion. This is true by default and query and scan will filter out the deleted items by default too.

await dinamo.delete({ key: { id: 'a' }, soft: true })

Deletes an item from the database.

await dinamo.delete({ key: { id: 'a' }, soft: false })

get

Gets a single item.

await dinamo.get({ key: { id: 'a' } })

increment

Increments an item. Step is optional.

await dinamo.increment({ key: { id: 'a' }, field: 'count', step: 1 })

put

Puts an item.

await dinamo.put({ item: { id: 'a', foo: 'bar' } })

query

Queries items from the database.

await dinamo.query({ key: { id: 'a' } })

With indexName.

await dinamo.query({ key: { id: 'a' }, indexName: 'dateIdIndex' })

Filtering items.

await dinamo.query({ key: { id: 'a' }, query: { foo: 'bar' } })

Disable filtering soft deletes.

await dinamo.query({ key: { id: 'a' }, filterDeleted: false })

Limiting items.

await dinamo.query({ key: { id: 'a' }, limit: 10 })

Reverse ordering items based on range key.

await dinamo.query({ key: { id: 'a' }, scanIndexForward: true })

scan

Scans items from the database.

await dinamo.scan({ query: { id: 'a' } })

Recursively scan items.

await dinamo.scan({ query: { id: 'a' }, recursive: true })

Disable filtering soft deletes

await dinamo.scan({ query: { id: 'a' }, filterDeleted: false })

update

Updates an item.

await dinamo.update({ key: { id: 'a' }, item: { foo: 'baz' } })

Contributing

Issues and pull requests are welcome.

License

MIT