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

ddb-orm

v0.0.3

Published

This is an abstraction for using [single table design] with [dynamodb]. > Inspired by mythical [Rick Houlihan](https://twitter.com/houlihan_rick)

Downloads

29

Readme

Dynamodb Single Table ORM

This is an abstraction for using single table design with dynamodb.

Inspired by mythical Rick Houlihan

THIS IS NOT READY YET: DON'T USE THIS

This is an alpha software and is currently in active development. Documentations and API are to be done.

Getting Started

yarn add ddb-orm aws-sdk
# or
npm --save install ddb-orm aws-sdk

Declare keys used in table

import { Key } from 'ddb-orm';

const PK = Key({ name: 'PK', sortKey: 'SK', isPrimaryIndex: true });
const SK = Key({ key: 'SK', sortKey: 'PK', index: 'InvertedIndex', });

Declare table properties

import { TableFactory } from 'ddb-orm'

const Table = TableFactory({
    name: 'SocialTable',
    keys: [PK, SK],
    useLocal: true,  // using locally running dynamodb
});

Create the table (optional)

await Table.create();

Define your entities

import { Entity, Attribute } from 'ddb-orm'

@Table  // attach our table instance to entity
class User extends Entity {
    @PK('USER')
    @SK('#METADATA')
    username: string;

    @Attribute
    name: string;
}

Save new user

const user = new User({ username: 'test_user', name: 'Test User' });
await user.save();

Find Multiple users

const users = await User.find({ where: { username: 'test_user' } });
console.log(users);

/*
    [
        User { 
                "username": "test_user",
                "name": "Test User",
                "PK": "USER#test_user",
                "SK": "#METADATA#test_user"
        }
    ]
*/

Find Particular user

const user = await User.findOne({ username: 'test_user' });
console.log(user);

/*
    User { 
        "username": "test_user",
        "name": "Test User",
        "PK": "USER#test_user",
        "SK": "#METADATA#test_user"
    }
*/

API Guide

Key

| Option | Description | Type | Required | Default | |----------------|----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|----------|---------------| | name | Key name for table. | string | YES | | | sortKey | Sort key for the particular index. | string | NO | | | index | Index key (and sort-key) if there is any. This will create a Global Secondary index for quering. Not required for primary index. | string | NO | | | isPrimaryIndex | Specify primary index for the table. | Boolean | NO | false | | projection | Projection type of index. | string(ALL | KEYS_ONLY | INCLUDE) | NO | ALL | | attributes | Only required for projection type INCLUDE. | Array<string> | NO | [] | | rcu | Read capacity units for Index. | number | NO | 3 | | wcu | Write capacity of the Index. | number | NO | 3 |

TableFactory

| Option | Description | Type | Required | Default | |----------|------------------------------------------------------------------------------------------------------------------------------|------------|----------|--------------| | name | Name of the table used. | string | YES | | | keys | Arrays of Key. (at-least primary key is required) | Array | YES | | | region | AWS region to be used for table. | string | NO | ap-south-1 | | endpoint | AWS dyanamodb endpoint. (http://localhost:8000 for local and for production https://dyanmodb.<aws-region>.amazonaws.com) | string | NO | | | useLocal | Use local dyanmodb instead of cloud. (You need to run dyanamodb locally first) | boolean | NO | |

Attribute

Marks any property as attribute.

Entity

TODO

Example

TODO