import { AttributeMap } from "aws-sdk/clients/dynamodb" import { PartitionAndSortKey } from "../keys" import { TaggedModel } from "../types" import { BaseParams } from "./BaseParams" export interface GetItemParams extends BaseParams { key: PartitionAndSortKey consistentRead?: boolean } export interface GetItemResult { item?: AttributeMap } export async function getItem(params: GetItemParams): Promise { const { table, client, key, consistentRead } = params const results = await client .get({ TableName: table.tableName, ConsistentRead: consistentRead, Key: { [table.partitionKeyName]: key.partitionKey, [table.sortKeyName]: key.sortKey } }) .promise() return { item: results.Item } }