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

@begin/data-alpha

v0.0.1

Published

Begin Data is a durable and fast key/value store for Begin built on top of DynamoDB.

Downloads

5

Readme

Begin Data

Codeship Status for smallwins/begin-data

Begin Data is a durable and fast key/value store built on top of DynamoDB with super simple storage/access patterns that are similar to Redis.

⚠️ Warning

@begin/data-alpha hasn't been enabled for Begin apps yet – do not attempt to use with your application.

But feel free to view source!

Concepts

Begin Data organizes itself into tables. Tables contain items which are just collections of plain Objects. Items stored in Begin Data always have the properties table and key. Optionally an item can also have a ttl property with a UNIX epoch value representing the expiry time for the item.

API

let data = require('@begin/data')

The core API is three methods:

  • data.get(params, [callback]) for retreiving data
  • data.set(params, [callback]) for writing data
  • data.destroy(params, [callback]) for removing data

Additional helper methods are also made available:

  • data.incr(params, [callback]) increment an attribute on an item
  • data.decr(params, [callback]) decrement an attribute on an item
  • data.count(params, [callback]) get the number of items for a given table

All methods require a params object and, optionally, a Node style errback. If no errback is supplied a promise is returned. All methods support async/await.

Writes

Save an item in a table by key. Remember table is always required.

let taco = await data.set({
  table: 'tacos', 
  key: 'al-pastor'
})

key is optional. But all items have a key. If no key is given set will generate a unique key.

let token = data.set({
  table: 'tokens', 
})
// {table:'tokens', key:'s89sdfjskfdj'}

Batch save multiple documents at once by passing an array of objects.

let collection = await data.set([
  {table: 'ppl', name:'brian', email:'[email protected]'},
  {table: 'ppl', name:'sutr0', email:'[email protected]'},
  {table: 'tacos', key:'pollo'},
  {table: 'tacos', key:'carnitas'},
])

Reads

Read an item by key:

let yum = await data.get({
  table: 'tacos', 
  key: 'baja'
})

Batch read by passing an array of objects. With these building blocks you can construct secondary indexes and joins like one-to-many and many-to-many.

await data.get([
  {table:'tacos', key:'carnitas'},
  {table:'tacos', key:'al-pastor'},
])

Or scan an entire table.

let users = data.get({table:'users'})
for await (let user of users()) {
  console.log(user) 
}

If you want to paginate pass a limit:

let users = data.get({table:'users', limit:10})
for await (let page of users()) {
  console.log(page) // array of 10 users 
}

Destroy

Delete an item by key.

await data.destroy({
  table: 'tacos', 
  key: 'pollo'
})

Batch delete items by passing an array of objects.

await data.destroy([
  {table:'tacos', key:'carnitas'},
  {table:'tacos', key:'al-pastor'},
])

Additional Superpowers

  • Documents can be expired by setting ttl to an UNIX epoch in the future.
  • Atomic counters: data.incr and data.decr

Patterns

Coming soon! Detailed guides for various data persistence tasks:

  • denormalizing
  • pagination
  • counters
  • secondary indexes
  • one to many
  • many to many