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

reach-deconstruct-item-store

v2.1.3

Published

A deconstruct-api module that enables a fast schema-less JSON object store for reverse-chronologically-ordered objects

Downloads

25

Readme

deconstruct-item-store

A deconstructed API storage paradigm, tailored around the deconstruct-api, but loosely coupled to a high enough degree to be used anywhere else.

It uses both redis and AWS DynamoDB to provide a very fast, scalable dehydrated/hydrated storage paradigm, using redis to store lists of data item id's, and DynamoDB for the fully hydrated items themselves.

installation

In your project folder:

  npm install --save deconstruct-item-store

Specify redis & DynamoDB connection parameters by means of the following environment variables:

    REDIS_PORT=<PORT>
    REDIS_HOST=<HOST>
    DYNAMO_TABLE=<TABLE>

items

An item is an atom of data - the smallest unit of data that you want to store.

Every item has a type, and every item is wrapped in an envelope of metadata when it is stored. By default this metadata envelope contains the attributes id, publishedTime, lastModifiedTime, and type. The item itself can be found in the item attribute.

The itemStore maintains these attributes, and for sinatnce, assigns a unique id every time an item is stored or updated. It also takes care of updating the timestamps.

config

Every type can also be specified to have an additional set of custom metadata attributes, as such:

    const config = {
        typeConfigs: {
            type1: {
                path: [ 'some', 'deep', 'attr' ],
                attrs: [ 'string', 'md5Hash' ]
            }
        }
    };

    itemStore.loadConfig ( config );

In the above code, the value of item.some.deep.attr will be converted to a string, an md5 hash will be calculated of it, and the result will be stored in the attr metadata attribute. A list of possible custom metadata attrs are:

string: convert to a string, if it's not already one
float: convert to a float, if it's not already one
int: convert to an integer, if it's not already one
boolean: convert to a boolean, if it's not already one
md5Hash: calculate the md5 hash of the value
uriLastPathComp: take only the last path component (after the last '/')
toLowerCase: convert the value to lower case

The attrs are applied from left to right, in series

The itemStore config can optionally specify redis and dynamo connection parameters, but these are best provided as environment variables (see installation above)

    const config = {
        redis: {
            host: <HOST>,
            port: <PORT>
        },
        dynamo: {
            table: <TABLE>
        }
    };

itemStore

    const itemStore = require ( 'deconstruct-item-store' ).itemStore

All the methods below are curried.

saveItem

    itemStore.saveItem ( stubs, type, id, prevItem, item, callback );

deleteItem

    itemStore.deleteItem ( stubs, type, id, item, callback );

getItem

    itemStore.getItem ( stubs, type, id, callback );

getItems

    itemStore.getItems ( stubs, type, query, callback );

getItemIds

    itemStore.getItemIds ( stubs, type, query, callback );

hydrateIds

    itemStore.hydrateIds ( stubs, type, ids, callback );

itemGenerator

    const itemGenerator = require ( 'deconstruct-item-store' ).itemGenerator