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

@socketsupply/dynavolt

v3.0.0

Published

A highly opinionated DynamoDB client for aws-sdk v3 using esm.

Downloads

8

Readme

SYNOPSIS

A highly opinionated DynamoDB client for aws-sdk v3 using esm.

USAGE

import Dynavolt from 'dynavolt'
const db = new Dynavolt({ region: 'us-west-2' })

TABLES

CREATE

const { err, data: table } = await db.create('artists')

You can also specify hash, range, and options.

const opts = { TimeToLiveSpecification: {
  AttributeName: 'ttl',
  Enabled: true
}

const { err } = await db.create('artists', 'genres', 'artists', opts)

OPEN

Open a database and optionally create it if it doesnt exist.

const { err, data: table } = await db.open('artists', { create: true })

METHODS

PUT

Dynavolt will automatically (and recursively) deduce the types of your data and annotate them correctly, so there is no need to write "dynamodb json".

const { err } = await table.put('glen', 'danzig', { height: 'quite-short' })

PUT IF NOT EXISTS

Dynavolt will automatically (and recursively) deduce the types of your data and annotate them correctly, so there is no need to write "dynamodb json".

const { err } = await table.put('glen', 'danzig', { height: 'quite-short' })

UPDATE

const expr = `SET count = count + N(${value})`

const { err, data } = await table.update('iggy', 'pop', expr)

GET

const { err, data } = await table.get('iggy', 'pop')

DELETE

const { err } = await table.delete('henry', 'rollins')

BATCH WRITE

const { err } = await table.batchWrite([
  ['foo', 'bar', { beep: 'boop' }],
  ['foo', 'bar']
])

BATCH READ

const { err } = await table.batchRead([
  ['foo', 'bazz'],
  ['beep', 'boop']
])

QUERY

Query takes a Key Condition Expression. For syntax refernece see the Comparison Operator and Function Reference.

const iterator = table.query(`hash = N(greetings) AND begins_with(range, S(hell))`)

for await (const { err, data: { key, value } } of iterator) {
  console.log(key, value)
}

You can also chain a Filter Expression and Projection Expression clauses onto querties. More info about Projection Expression syntax here.

const iterator = table
  .query(`hash = N(songs) AND begins_with(range, S(moth))`)
  .filter(`contains(artists.name, S(danzig)`)
  .properties('artists.weight', 'artists.height')

for await (const { err, data: { key, value } } of iterator) {
  console.log(key, value)
}

SCAN

Scan takes a Filter Expression.

const iterator = table.scan(`contains(artists.name, S(danzig)`)

for await (const { err, data: { key, value } } of iterator) {
  console.log(key, value)
}

TTL

Records in your database can be set to expire by specifying a TTL attribute on your table.

const { err } = await table.setTTL('stillCool')

Now one minute after adding the following record, it will be removed.

const opts = {
  stillCool: 6e4
}

const { err } = await table.put('brian', 'setzer', { cool: true }, opts)