UNPKG

duenamodb

Version:

Simple, strongly-typed helpers around the AWS SDK DynamoDB client.

18 lines (17 loc) 1.09 kB
import { type GetItemCommandInput } from "@aws-sdk/client-dynamodb"; import type { DynamoDBTypes, PK, SK } from "./types"; type GetDynamoOptions = Omit<GetItemCommandInput, "TableName" | "Key">; type GetItemOptions<TPK extends PK, TSK extends SK> = { pk: TPK; sk?: TSK; dynamodbOptions?: GetDynamoOptions; }; export type GetItemFunction<Attributes extends DynamoDBTypes, TPK extends PK, TSK extends SK = undefined> = (options: GetItemOptions<TPK, TSK>) => Promise<Attributes | undefined>; type CreateGetItemOptions<Attributes extends DynamoDBTypes> = { tablename: string; pkName: keyof Attributes; skName?: keyof Attributes; }; export declare const createGetItem: <Attributes extends DynamoDBTypes, TPKN extends keyof Attributes = keyof Attributes, TSKN extends keyof Attributes = keyof Attributes>(options: CreateGetItemOptions<Attributes>) => GetItemFunction<Attributes, Attributes[TPKN], Attributes[TSKN]>; export declare const getItem: <T>(tablename: string, key: GetItemCommandInput["Key"], options?: GetDynamoOptions) => Promise<T | undefined>; export {};