Skip to content

chiefbiiko/dynamodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamodb

ci

DynamoDB client.

Usage

import { createClient } from "https://denopkg.com/chiefbiiko/dynamodb/mod.ts";

// if config/credentials not passed they will be read from the env/fs
const dyno = createClient();

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

The client config can be omitted entirely when calling createClient. If that is the case the config will be derived from the environment and filesystem, in that order, using get-aws-config.

Prefer using temporary credentials and a session token.

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 | Promise<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

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.

BatchGetItem

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

aws BatchGetItem docs

BatchWriteItem

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

aws BatchWriteItem docs

CreateBackup

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

aws CreateBackup docs

CreateGlobalTable

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

aws CreateGlobalTable docs

CreateTable

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

aws CreateTable docs

DeleteBackup

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

aws DeleteBackup docs

DeleteItem

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

aws DeleteItem docs

DeleteTable

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

aws DeleteTable docs

DescribeBackup

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

aws DescribeBackup docs

DescribeContinuousBackups

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

aws DescribeContinuousBackups docs

DescribeEndpoints

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

aws DescribeEndpoints docs

DescribeGlobalTable

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

aws DescribeGlobalTable docs

DescribeGlobalTableSettings

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

aws DescribeGlobalTableSettings docs

DescribeLimits

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

aws DescribeLimits docs

DescribeTable

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

aws DescribeTable docs

DescribeTimeToLive

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

aws DescribeTimeToLive docs

GetItem

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

aws GetItem docs

ListBackups

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

aws ListBackups docs

ListGlobalTables

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

aws ListGlobalTables docs

ListTables

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

aws ListTables docs

ListTagsOfResource

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

aws ListTagsOfResource docs

PutItem

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

aws PutItem docs

Query

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

aws Query docs

RestoreTableFromBackup

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

aws RestoreTableFromBackup docs

RestoreTableToPointInTime

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

aws RestoreTableToPointInTime docs

Scan

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

aws Scan docs

TagResource

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

aws TagResource docs

TransactGetItems

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

aws TransactGetItems docs

TransactWriteItems

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

aws TransactWriteItems docs

UntagResource

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

aws UntagResource docs

UpdateContinuousBackups

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

aws UpdateContinuousBackups docs

UpdateGlobalTable

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

aws UpdateGlobalTable docs

UpdateGlobalTableSettings

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

aws UpdateGlobalTableSettings docs

UpdateItem

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

aws UpdateItem docs

UpdateTable

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

aws UpdateTable docs

UpdateTimeToLive

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

aws UpdateTimeToLive docs

FYI

Don't want to do all development against the real AWS cloud?

License

MIT

About

deno <3 dynamodb

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •