DynamoDB client.
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.
/** 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]
}
createClient(conf: ClientConfig): DynamoDBClient
Creates a DynamoDB client.
The client supports all DynamoDB operations. Check the linked aws docs for info about parameters of a specific operation.
batchGetItem(params: Doc, options?: OpOptions): Promise<Doc>
batchWriteItem(params: Doc, options?: OpOptions): Promise<Doc>
createBackup(params: Doc, options?: OpOptions): Promise<Doc>
createGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
createTable(params: Doc, options?: OpOptions): Promise<Doc>
deleteBackup(params: Doc, options?: OpOptions): Promise<Doc>
deleteItem(params: Doc, options?: OpOptions): Promise<Doc>
deleteTable(params: Doc, options?: OpOptions): Promise<Doc>
describeBackup(params: Doc, options?: OpOptions): Promise<Doc>
describeContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>
aws DescribeContinuousBackups docs
describeEndpoints(options?: OpOptions): Promise<Doc>
describeGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
describeGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>
aws DescribeGlobalTableSettings docs
describeLimits(options?: OpOptions): Promise<Doc>
describeTable(params: Doc, options?: OpOptions): Promise<Doc>
describeTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>
getItem(params: Doc, options?: OpOptions): Promise<Doc>
listBackups(params: Doc, options?: OpOptions): Promise<Doc>
listGlobalTables(params: Doc, options?: OpOptions): Promise<Doc>
listTables(options?: OpOptions): Promise<Doc>
listTagsOfResource(params: Doc, options?: OpOptions): Promise<Doc>
putItem(params: Doc, options?: OpOptions): Promise<Doc>
query(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>
restoreTableFromBackup(params: Doc, options?: OpOptions): Promise<Doc>
aws RestoreTableFromBackup docs
restoreTableToPointInTime(params: Doc, options?: OpOptions): Promise<Doc>
aws RestoreTableToPointInTime docs
scan(params: Doc, options?: OpOptions): Promise<Doc | AsyncIterableIterator<Doc>>
tagResource(params: Doc, options?: OpOptions): Promise<Doc>
transactGetItems(params: Doc, options?: OpOptions): Promise<Doc>
transactWriteItems(params: Doc, options?: OpOptions): Promise<Doc>
untagResource(params: Doc, options?: OpOptions): Promise<Doc>
updateContinuousBackups(params: Doc, options?: OpOptions): Promise<Doc>
aws UpdateContinuousBackups docs
updateGlobalTable(params: Doc, options?: OpOptions): Promise<Doc>
updateGlobalTableSettings(params: Doc, options?: OpOptions): Promise<Doc>
aws UpdateGlobalTableSettings docs
updateItem(params: Doc, options?: OpOptions): Promise<Doc>
updateTable(params: Doc, options?: OpOptions): Promise<Doc>
updateTimeToLive(params: Doc, options?: OpOptions): Promise<Doc>
Don't want to do all development against the real AWS cloud?