UNPKG

duenamodb

Version:

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

22 lines (21 loc) 1.47 kB
import { type QueryCommandInput } from "@aws-sdk/client-dynamodb"; import { type SortKeyCondition, type FilterCondition } from "./expression"; import type { DynamoDBTypes, PK, SK } from "./types"; type CreateQueryItemsOptions<Attributes extends DynamoDBTypes> = { tablename: string; indexName?: string; pkName: keyof Attributes; skName?: keyof Attributes; }; type QueryDynamoDBOptions = Omit<QueryCommandInput, "TableName">; export type QueryOptions<Attributes extends DynamoDBTypes, TPK extends PK, TSK extends SK> = { pk: TPK; sk?: SortKeyCondition<TSK>; filter?: FilterCondition<Attributes>; dynamodbOptions?: QueryDynamoDBOptions; }; export type QueryItemsFunction<Attributes extends DynamoDBTypes, TPK extends PK, TSK extends SK = undefined> = (options: QueryOptions<Attributes, TPK, TSK>) => Promise<Attributes[]>; export declare const createQueryItems: <Attributes extends DynamoDBTypes, TPKN extends keyof Attributes = keyof Attributes, TSKN extends keyof Attributes = keyof Attributes>(options: CreateQueryItemsOptions<Attributes>) => QueryItemsFunction<Attributes, Attributes[TPKN], Attributes[TSKN]>; export declare const createQueryOptions: <Attributes extends DynamoDBTypes>(keyOptions: Partial<Attributes>, index?: string, filter?: FilterCondition<Attributes> | undefined) => Partial<QueryDynamoDBOptions>; export declare const queryItems: <T>(tablename: string, options: QueryDynamoDBOptions) => Promise<T[]>; export {};