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

yammer-kvs

v1.1.0

Published

Yammer Key Value Store

Downloads

5

Readme

yammer-kvs

Yammer Key/Value Store.

NPM

This package wraps around AWS's DynamoDB and turns it into a Key/Value Store (KVS). Keys are optionally of a fixed schema (see Validation). It's even about 4% faster than using aws-sdk! (tested reading a single key's value multiple times)

It expects that you have a primary key named key. See this document for DynamoDB configuration instructions.

Reference

Read

Single record

Reads a single value from a given key.

Usage:

await yammerkvs.read.single('MY_KEY')

Sample response:

'This is the value of MY_KEY'

One or more records

Reads one or more records from one or more given keys.

Usage:

await yammerkvs.read.multiple([
  'MY_KEY',
  'MY_KEY2'
]);

Sample response:

{
  MY_KEY: 'This is the value of MY_KEY',
  MY_KEY2: 'This is the value of MY_KEY2'
}

Update/insert

Single record

Upserts a single key/value pair.

Usage:

await yammerkvs.update.single({
  MY_KEY: 'New value for MY_KEY.'
});

Sample response:

{
  MY_KEY: 'New value for MY_KEY.'
}

One or more records

Upserts one or more key/value pairs.

Usage:

await yammerkvs.update.multiple({
  MY_KEY: 'Another value for MY_KEY',
  MY_KEY2: 'New value for MY_KEY2'
});

Sample response:

{ 
  UnprocessedItems: {}
}

Config

Set

Set as many or as few config vars as you'd like.

yammerkvs.config.set({
  /*
    Used as a prefix when reading and writing keys.
    Once you define this prefix in config, you won't see it again--
    All of your requests will prepended with your prefix, and all
    responses will have the prefix removed.
    Optional; defaults to no prefix.
  */
  Prefix: 'YMR_',
  /*
    Allows you to set the name of your DynamoDB Table.
    Optional; this defaults to 'yammer_kvs'
  */
  TableName: 'yammer_kvs',
  /*
    Allows you to choose whether you'd like to validate your keys
    to the schema at the bottom of the README. Uppercase letters,
    underscores and numbers are only allowed when this is enabled.
  */   
  ValidateKeys: false
});

This will return the new config object, so the same response you'd get from yammerkvs.config.get().

Set AWS

Allows you to access the DynamoDB constructor to add things like region, access key id, etc. See this document from AWS about the options you can put in here.

yammerkvs.config.aws.configUpdate({
  region: 'us-east-2',
  endpoint: 'https://dynamodb.us-east-2.amazonaws.com'
})

Set region

Allows you to set only the AWS region.

yammerkvs.config.aws.setRegion('us-east-2')

Validation

This section only applies if ValidateKeys is set to true in your config. It's false by default.

yammer_kvs only accepts keys that match this regex: /[A-Z0-9_]+/. You'll recieve an error if a specified key doesn't match. All keys in a query must match to be sent to Amazon.

Examples:

  • MY_KEY - uppercase letters and underscores only
  • MY_2ND_KEY - ^
  • my_key - lowercase letters are not allowed
  • MY-KEY - dashes are not allowed
  • THIS_KEY_IS_$12.49 - $ and . not allowed

Your request will also error out if you have a key without a value.