Catalog npm
Back to packageRELEASE DETAILS

0.3.0

npm

@0to10/aws-dynamodb

Typescript library for working with DynamoDB tables

awsdynamodblambdarepository
Published12 Feb 2025
Direct dependencies13
Transitive dependenciesNot calculated

README

Current package documentation

AWS DynamoDB library

This repository provides a library to work with DynamoDB tables.

Getting started

Get started quickly by following the instructions below.

Installation

Use NPM to install this library into your project:

npm install --save @0to10/aws-dynamodb

Basic usage

Implementing a repository is easy. Create a new class and extend the abstract Repository class that the library exposes.

After implementing the abstract hydrate method you can start using the findBy and findOneBy methods of the repository right away. No additional configuration or methods are needed.

The findBy and findOneBy methods both accept an object of criteria, where the key is the field that is matched and the value is the value of the field. You may use a wildcard at the end of a value to perform a "begins_with" search on the DynamoDB table.

The findBy method accepts a second argument to adjust the limit of the query.

'use strict';

import {NativeAttributeValue} from '@aws-sdk/util-dynamodb';

import {Repository} from '@0to10/aws-dynamodb';

class EntityRepository extends Repository<Entity> {

    protected hydrate(item: Record<string, NativeAttributeValue>): Entity {
        return new Entity(item);
    }

}

Additional methods

Any convenience methods may be added to the repository:

In the example below, two methods have been added: findOneByName and findByName. You may choose to run a custom query by calling the protected query method or call any of the public methods.

'use strict';

import {QueryCommandInput} from '@aws-sdk/client-dynamodb';
import {NativeAttributeValue} from '@aws-sdk/util-dynamodb';

import {Repository} from '@0to10/aws-dynamodb';

class EntityRepository extends Repository<Entity> {

    public async findOneByName(name: string): Promise<Entity> {
        const params: QueryCommandInput = {
            // Define your search params
        };

        return this.query(params);
    }

    public async findByName(name: string): Promise<Entity[]> {
        return this.findBy({
            name_field: name,
        });
    }

    protected hydrate(item: Record<string, NativeAttributeValue>): Entity {
        return new Entity(item);
    }

}

Return values

When using and implementing a Repository class, please note:

  • The hydrate method must always return a single hydrated document
  • The findOneBy method will always return a single entity or undefined if no result was found
  • The findBy method always returns an array of entities (which may be empty)

You may typehint for an Array-like return when using the findBy method, but be aware that the actual return type is a Collection (which extends Array). The Collection class exposes a LastEvaluatedKey variable with which you can run consecutive queries for when you need more results than the specified limit.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 13

Native requirements
13 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.0development
tslib
Environment
{
  "local_name": "tslib",
  "alias": false,
  "peer_metadata": null
}
^2.2.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.56.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.0development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
~18.17.19development
@jest/globals
Environment
{
  "local_name": "@jest/globals",
  "alias": false,
  "peer_metadata": null
}
^29.5.0development
@types/aws-lambda
Environment
{
  "local_name": "@types/aws-lambda",
  "alias": false,
  "peer_metadata": null
}
~8.10.122development
@aws-sdk/util-dynamodb
Environment
{
  "local_name": "@aws-sdk/util-dynamodb",
  "alias": false,
  "peer_metadata": null
}
~3.606.0development
@aws-sdk/client-dynamodb
Environment
{
  "local_name": "@aws-sdk/client-dynamodb",
  "alias": false,
  "peer_metadata": null
}
^3.629.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^6.19.0development
eslint-plugin-deprecation
Environment
{
  "local_name": "eslint-plugin-deprecation",
  "alias": false,
  "peer_metadata": null
}
^2.0.0development
license-checker-rseidelsohn
Environment
{
  "local_name": "license-checker-rseidelsohn",
  "alias": false,
  "peer_metadata": null
}
^4.3.0development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^6.19.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "2bdcb3179b3a83eddf034a3bc9e41450933bd0cb",
  "tarball": "https://registry.npmjs.org/@0to10/aws-dynamodb/-/aws-dynamodb-0.3.0.tgz",
  "fileCount": 45,
  "integrity": "sha512-36L3MGjg58xV8ykxxck4n7N3IbW2F74WvODEGiwvvrRQfsItXbkEfTIyGV5v8nyDoHaWppZ3BbT0EhZWURjPMQ==",
  "signatures": [
    {
      "sig": "MEUCIQDb2kg8coILw51n/MBZ4f5T+iQ++W0lSHnYep1rigafigIgObwv+b0RE/ThZOxze2uwmeuJgOCElc8O7ILYQ+UhYOY=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 33030
}

Repository

PENDING
0to10/aws-dynamodb-library-ts

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:16 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:30074300591f047be33f52757e5f709bccb900801fd2c19d5a3a6ca48481e847

Other collected versions

1.0.023 Feb0.4.017 Feb0.2.09 Feb0.1.09 FebView all collected versions →