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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dynamodeve

v1.0.5

Published

Dynamodb wrapper to simplify the use of the AWS SDK

Readme

Dynamodeve

An easier method to use AWS DynamoDB. It handles index generation but giving you more control to declare indexes and query patterns.

Install

npm install dynamodeve

Setup

  1. Declare your table configuration
// db_config.ts

const TABLE_NAME = 'main';

export const PRIMARY_INDEX_CONFIG = {
    tableName: TABLE_NAME,
    indexName: null,
    partitionKey: 'PK',
    sortKey: 'SK',
} as const;

export const GSI1_CONFIG = {
    tableName: TABLE_NAME,
    indexName: 'GSI1',
    partitionKey: 'GSI1PK',
    sortKey: 'GSI1SK',
} as const;

export const GSI2_CONFIG = {
    tableName: TABLE_NAME,
    indexName: 'GSI2',
    partitionKey: 'GSI2PK',
    sortKey: 'GSI2SK',
} as const;
  1. Create a model using the configuration
// user.ts

type User = {
    givenName: string;
    lastName: string;
    email: string;
    nationalId: string;
}

Declare your model entity name

const ENTITY_NAME = 'User';

Declare your model index configuration, for this step you can use curly braces as template fields for the lib to generate your indexes

// user.ts

const INDEX_FIELDS_MAP: IndexFieldsMap = {
    [PRIMARY_INDEX_CONFIG.partitionKey]: [ENTITY_NAME, '{id}'],
    [PRIMARY_INDEX_CONFIG.sortKey]: [ENTITY_NAME],
    [GSI1_CONFIG.partitionKey]: [ENTITY_NAME],
    [GSI1_CONFIG.sortKey]: [ENTITY_NAME, '{email}'],
    [GSI2_CONFIG.partitionKey]: [ENTITY_NAME],
    [GSI2_CONFIG.sortKey]: [ENTITY_NAME, '{nationalId}'],
};

After index generation the above will generate indexes like

PK: User#937c1e16-cb48-454d-825b-7398ab990d91
SK: User

GSI1PK: User
GSI1SK: User#[email protected]

GSI2PK: User
GSI2SK: User#13812718

The next step is to declare your wrapper model

// user.ts

export class Handler extends DbModel<Entity> {
    constructor(pkPrefix: string) {
        super(pkPrefix, ENTITY_NAME, PRIMARY_INDEX_CONFIG, INDEX_FIELDS_MAP);
    }

    // Primary Access patterns

    public async findOneById(id: string): Promise<Entity | null> {
        return this.queryOne({ id }, PRIMARY_INDEX_CONFIG, { skMatch: 'exact' });
    }

    // GSI1 Access patterns

    public async find(config: PaginationConfig = {}): Promise<PaginatedDbResult<Entity[]>> {
        return await this.query({}, GSI1_CONFIG, { ...config, skMatch: 'begins_with' });
    }

    public async findOneByEmail(email: string): Promise<Entity | null> {
        return this.queryOne({ email }, GSI1_CONFIG, { skMatch: 'exact' });
    }

    // GSI2 Access patterns

    public async findOneByNationalId(nationalId: string): Promise<Entity | null> {
        return this.queryOne({ nationalId }, GSI2_CONFIG, { skMatch: 'exact' });
    }

    // CRUD operations

    public async createOne(input: WithoutDefaults<Entity>): Promise<Entity> {
        const { id } = this.trxInsertOne(input);

        this.trxInsertUniqueConstraint([input.email]);

        if (input.nationalId) {
            this.trxInsertUniqueConstraint([input.nationalId]);
        }

        await this.trxExecute();

        const createdResource = await this.findOneById(id);
        if (createdResource === null) {
            throw new Error('Failed to find resource after create');
        }

        return createdResource;
    }

    public async updateOne(id: string, input: Partial<WithoutDefaults<Entity>>, filter: Partial<Entity> = {}): Promise<Entity | null> {
        const resource = await this.findOneById(id);
        if (resource === null) return null;

        this.trxUpdateOne(input, resource, filter);

        if (input.email && input.email !== resource.email) {
            this.trxRemoveUniqueConstraint([resource.email]);
            this.trxInsertUniqueConstraint([input.email]);
        }

        if (input.nationalId && input.nationalId !== resource.nationalId) {
            if (resource.nationalId) {
                this.trxRemoveUniqueConstraint([resource.nationalId]);
            }
            this.trxInsertUniqueConstraint([input.nationalId]);
        }

        await this.trxExecute();

        return this.findOneById(id);
    }

    public async deleteOne(id: string, filter: Partial<Entity> = {}): Promise<Entity | null> {
        const resource = await this.findOneById(id);
        if (resource === null) return null;

        this.trxDeleteOne(resource, filter);

        this.trxRemoveUniqueConstraint([resource.email]);

        if (resource.nationalId !== undefined) {
            this.trxRemoveUniqueConstraint([resource.nationalId]);
        }

        await this.trxExecute();

        return resource;
    }
}