Skip to content

ericdmoore/dynamodb-deno

 
 

Repository files navigation

dynamodb-deno

CI Badge Coverage Badge

DynamoDB client that loves Deno - forked from chiefbiiko

Usage

import { createClient } from 'https://denopkg.com/ericdmoore/dynamodb-deno/mod.ts';

// config/credentials WILL NOT BE READ from the env/fs
// you MUST pass them in
// you can OPTIONALLY use chiefbiiko's other pkg to handle that if you like
//
// import { get as grabAwsCreds } from "https://denopkg.com/chiefbiiko/get-aws-config/mod.ts";

const dyno = createClient({ credentials: grabAwsCreds() });

// the client has all of DynamoDB's operations as camelCased async methods
const result = await dyno.listTables();

Fork Reason

Philosophically I perfer my libraries to not escalate permissions. The chiefbiiko package is incredible, however, I prefer clarity over convenience. It has some of automagically fetching credentials functions, and I leave those to the user's application. As shown in the Usage documentation above; it assumes the user can manage their own credentials, but if that it too dificult, users can recreate a similar experience by leveraging the oother chiefbiiko package.

There have also been some non-material stylistic changes - since I intend to maintain this fork.

Roadmap

The goal for this project is to keep this project working until aws-sdk-js-v3/clients/client-dynamodb works via something like esm.sh

If you know of a deno package adapter service that works well with the offcial aws v3 dynamo client, please submit an issue to me so I can stop proping this package up, and just use the official one.

API

Contents

  1. Basics

  2. Factory

  3. Ops

Basics

/** Generic document. */
export interface Doc {
    [key: string]: any;
}

/** Generic representation of a DynamoDB client. */
export interface DynamoDBClient {
    describeEndpoints: (options?: Doc) => Promise<Doc>;
    describeLimits: (options?: Doc) => Promise<Doc>;
    listTables: (options?: Doc) => Promise<Doc>;
    scan: (
        params: Doc,
        options?: Doc,
    ) => Promise<Doc | AsyncIterableIterator<Doc>>;
    query: (
        params: Doc,
        options?: Doc,
    ) => Promise<Doc | AsyncIterableIterator<Doc>>;
    [key: string]: (params: Doc, options?: Doc) => Promise<Doc>;
}

/** Credentials. */
export interface Credentials {
    accessKeyId: string; // AKIAIOSFODNN7EXAMPLE
    secretAccessKey: string; // wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
    sessionToken?: string; // somesessiontoken
}

/** Client configuration. */
export interface ClientConfig {
    credentials: Credentials | (() => Credentials);
    region?: string; // us-west-2
    profile?: string; // default
    canonicalUri?: string; // fx /path/to/somewhere
    port?: number; // 80
    host?: string; // localhost
}

/** Op options. */
export interface OpOptions {
    wrapNumbers?: boolean; // wrap numbers to a special number value type? [false]
    convertEmptyValues?: boolean; // convert empty strings and binaries? [false]
    translateJSON?: boolean; // translate I/O JSON schemas? [true]
    iteratePages?: boolean; // if a result is paged, async-iterate it? [true]
}

Factory

createClient(conf: ClientConfig): DynamoDBClient

Creates a DynamoDB client.

Ops

The client supports all DynamoDB operations. Check the linked aws docs for info about parameters of a specific operation.

  1. batchGetItem(params: Doc, options?: OpOptions): Promise<Doc>

  2. batchWriteItem(params: Doc, options?: OpOptions): Promise<Doc>

  3. createBackup(params: Doc, options?: OpOptions): Promise<Doc>

  4. createGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>

  5. createTable(params: Doc, options?: OpOptions): Promise<Doc>

  6. deleteBackup(params: Doc, options?: OpOptions): Promise<Doc>

  7. deleteItem(params: Doc, options?: OpOptions): Promise<Doc>

  8. deleteTable(params: Doc, options?: OpOptions): Promise<Doc>

  9. describeBackup(params: Doc, options?: OpOptions): Promise<Doc>

  10. describeContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>

  11. describeEndpoints(options?: OpOptions): Promise<Doc>

  12. describeGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>

  13. describeGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>

  14. describeLimits(options?: OpOptions): Promise<Doc>

  15. describeTable(params: Doc, options?: OpOptions): Promise<Doc>

  16. describeTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>

  17. getItem(params: Doc, options?: OpOptions): Promise<Doc>

  18. listBackups(params: Doc, options?: OpOptions): Promise<Doc>

  19. listGlobalTables(params: Doc, options?: OpOptions): Promise<Doc>

  20. listTables(options?: OpOptions): Promise<Doc>

  21. listTagsOfResource(params: Doc, options?: OpOptions): Promise<Doc>

  22. putItem(params: Doc, options?: OpOptions): Promise<Doc>

  23. query(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>

  24. restoreTableFromBackup(params: Doc, options?: OpOptions): Promise<Doc>

  25. restoreTableToPointInTime(params: Doc, options?: OpOptions): Promise<Doc>

  26. scan(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>

  27. tagResource(params: Doc, options?: OpOptions): Promise<Doc>

  28. transactGetItems(params: Doc, options?: OpOptions): Promise<Doc>

  29. transactWriteItems(params: Doc, options?: OpOptions): Promise<Doc>

  30. untagResource(params: Doc, options?: OpOptions): Promise<Doc>

  31. updateContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>

  32. updateGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>

  33. updateGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>

  34. updateItem(params: Doc, options?: OpOptions): Promise<Doc>

  35. updateTable(params: Doc, options?: OpOptions): Promise<Doc>

  36. updateTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>

License

MIT

About

deno + dynamodb = <3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.2%
  • Other 0.8%