UNPKG

@moicky/dynamodb

Version:

Contains a collection of convenience functions for working with AWS DynamoDB

44 lines (43 loc) 1.69 kB
import { Get, TransactGetItemsCommandInput } from "@aws-sdk/client-dynamodb"; import { DynamoDBItem } from "../types"; /** * Performs a TransactGetItems operation against DynamoDB. This allows you to retrieve many items at once. * @param keys - Array of items to retrieve. Each item requires a `key` property, with at least the partition and the sort key (according to the table definition). * @param args - The additional arguments to override or specify for {@link TransactGetItemsCommandInput} * @returns A promise that resolves to an unmarshalled items array * * @example * Get items from the default-table * ```javascript * const items = await transactGetItems([ * { key: { PK: "User/1", SK: "Book/1", title: "The Great Gatsby", released: 1925 }}, * { key: { PK: "User/1", SK: "Book/2" }}, * { key: { PK: "User/1", SK: "Book/3" }}, * ]); * ``` * @example * Get items from a different tables * ```javascript * const items = await transactGetItems([ * { TableName: "yourTable", key: { PK: "User/1", SK: "Book/2" }}, * { TableName: "yourOtherTable", key: { PK: "User/1", SK: "Book/3" }}, * ]); * ``` * @example * Get all items from a non-default table * ```javascript * const items = await transactGetItems( * [ * { key: { PK: "User/1", SK: "Book/2" } }, * { key: { PK: "User/1", SK: "Book/3" } }, * ], * { TableName: "yourTable" } * ); * ``` */ export declare function transactGetItems<T extends DynamoDBItem = DynamoDBItem>(keys: Array<Omit<Get, "TableName" | "Key"> & { key: T; TableName?: string; }>, args?: Partial<TransactGetItemsCommandInput & { TableName?: string; }>): Promise<Array<T | undefined>>;