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

kixx-rynodb

v2.3.0

Published

An enhanced Dynamodb store for Kixx applications

Downloads

13

Readme

Kixx RynoDB

An enhanced Dynamodb store for Kixx applications.

End to End Tests

The end to end tests are designed to test features and functionality of the DynamoDB client and an actual AWS DynamoDB endpoint. Each test in the end-to-end-tests/ folder can be run independently by running:

node end-to-end-tests/[TEST_FILE].js

Or, all the tests can be run with:

node end-to-end-tests/all.js

The expected AWS credentials will need to be set:

export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_REGION=pick-a-region

And, you'll want to set a useful DEBUG setting, otherwise there will be no console output:

export DEBUG='kixx-rynodb:*'

!GOTCHA: A full set of tables will be set up by the setup-schema test using the table prefix "ttt". These tables will need to be removed before the next full test run.

DynamoDB Schema

Entities Table

Holds all database records as JSON serialized objects.

Name: PREFIX_entities_master

Record

{
    _scope: STRING,
    _type: STRING,
    _id: STRING,
    _scope_type_key: STRING,
    _created: ISO_DATE_STRING,
    _updated: ISO_DATE_STRING,
    _meta: HASH_OBJECT,
    _index_entries: HASH_OBJECT
    ...attributes
}

Key | Name | Value --------------------- | ----------------- | ----- Primary partition key | _id | The subject ID String Primary sort key | _scope_type_key | Compound SCOPE:TYPE String

Index name: PREFIX_entities_by_type

Key | Name | Value ------------- | ----------------- | ----- Partition key | _scope_type_key | Compound SCOPE:TYPE String Sort key | _updated | The subject updated ISO Date String

Index Lookup Table

Holds all index entries emittied from mapping functions.

Name: PREFIX_index_entries

Record

{
    _scope: STRING,
    _type: STRING,
    _id: STRING,
    _index_name: STRING, // Also the name of the map function.
    _index_key: STRING, // The index value created by the map function.
    _subject_key: `${scope}:${type}:${id}`,
    _unique_key: `${index_name}:${index_key}`,
    _scope_index_name: `${scope}:${index_name}`,
    ...attributes
}

Key | Name | Value --------------------- | -------------- | ----- Primary partition key | _subject_key | Compound SCOPE:TYPE:ID String Primary sort key | _unique_key | Compound INDEX_NAME:INDEX_KEY String

Index name: PREFIX_index_lookup

Key | Name | Value ------------- | ------------------- | ----- Partition key | _scope_index_name | Compound SCOPE:INDEX_NAME String Sort key | _index_key | The index value created by the map function.

Schema Use Cases

Get subject by ID: Use subject scope, type, and id to getItem() from entities_master table.

Page all subjects by type: Use subject scope and type to query(scope_type_key) from entities_by_type index.

Get relationship keys for subject: Use subject scope, type, and id to query() from relationship_entries table.

Get relationship objects for subject: Use subject scope, type, and id to query() from relationship_entries table. Then, use batchGet() to get the objects from the entities_master table.

Get relationship keys by predicate for subject: Use subject scope, type, id, and predicate to query(scope_type_key).begins_with(predicate) from relationship_entries table.

Get relationship objects by predicate for subject: Use subject scope, type, id, and predicate to query(scope_type_key).begins_with(predicate) from relationship_entries table. Then, use batchGet() to get the objects from the entities_master table.

Query objects from index: Use index scope and name to query(scope_name).anyOtherRangeQuery() from index_lookup. Use returned scope, type, and id to batchGet() items from entities_master.

Delete a record: Use object scope, type, and id to query(object_key) reverse_relationships index. Then, use batchWriteItem() to delete items from relationship_entries using returned subject_key and predicate_key. In parallel, Use object scope, type, and id to query(subject_key) index_entries. Then, use batchWriteItem() to delete items from index_entries using returned subject_key and unique_key. Finally deleteItem() from the entities_master table using the scope, type, and id.

Set a record: First, use putItem() to set the record in entities_master. If there are any relationships on the record, replace them (see Replace relationships on subject below).

Remove some relationships from subject: Use subject scope, type, id and predicate key to query(subject_key).begins_with(predicate) relationship_entries table. Then, use batchWriteItem() to delete records from relationship_entries using the returned subject_key and predicate_key.

Add some relationships on subject: Use subject scope, type, id and predicate key to query(subject_key).begins_with(predicate) relationship_entries table. Concat new entries, then dedupe them using the returned subject_key and predicate_key. Then, use batchWriteItem() to add new records to relationship_entries.

Replace relationships on subject: Use subject scope, type, id and predicate key to query(subject_key).begins_with(predicate) relationship_entries table. Then, use batchWriteItem() to delete records from relationship_entries using the returned subject_key and predicate_key. Finally, use batchWriteItem() to add all the new records to relationship_entries.

Copyright and License

Copyright: (c) 2017 by Kris Walker (www.kixx.name)

Unless otherwise indicated, all source code is licensed under the MIT license. See MIT-LICENSE for details.