UNPKG

duenamodb

Version:

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

22 lines (21 loc) 1.34 kB
import { type UpdateItemCommandInput } from "@aws-sdk/client-dynamodb"; import { type Keys } from "./object"; import type { DynamoDBTypes } from "./types"; type DynamoDBOptions = Omit<UpdateItemCommandInput, "TableName">; export type UpdateItemOptions<T> = { updateKeys?: Keys<T>; removeKeys?: Keys<T>; dynamodbOptions?: DynamoDBOptions; }; export type UpdateItemFunction<Attributes extends DynamoDBTypes> = (item: Attributes, options: UpdateItemOptions<Attributes>) => Promise<Attributes | undefined>; type CreateUpdateItemOptions<Attributes extends DynamoDBTypes> = { tablename: string; pkName: keyof Attributes; skName?: keyof Attributes; }; export declare const createUpdateItem: <Attributes extends DynamoDBTypes>(options: CreateUpdateItemOptions<Attributes>) => UpdateItemFunction<Attributes>; export declare const createUpdateExpression: (keys: string[]) => string | undefined; export declare const createRemoveExpression: (keys: string[]) => string | undefined; export declare function createUpdateOptions<Attributes extends DynamoDBTypes>(pkName: keyof Attributes, skName: keyof Attributes | undefined, updatedObject: Attributes, options: UpdateItemOptions<Attributes>): DynamoDBOptions | undefined; export declare const updateItem: (tableName: string, input: DynamoDBOptions) => Promise<boolean>; export {};