UNPKG

@setho/dynamodb-repository

Version:

DynamoDB repository for hash-key and hash-key/range indexed tables. Designed for Lambda use. Handles nice-to-haves like created and updated timestamps and default id creation.

33 lines (32 loc) 1.24 kB
import { ConstructorArgs } from './types'; declare class KeyValueRepository { private tableName; private keyName; private idOptions?; private docClient; private updateExpressionsBuilder; /** * Create a HashKey Repository * @param {Object} param - The constructor parameter * @param {string} param.tableName - The name of your DynamoDB table * @param {string} param.keyName - The name of your Hash/Partition Key property * @param {Object} param.documentClient - Injectable DynamoDBDocumentClient (v3) from @aws-sdk/lib-dynamodb * @param {Object} [param.idOptions] - The idOptions parameter * @param {string} [param.idOptions.prefix=] - The prefix of your id */ constructor(input: ConstructorArgs); get(hashKey: string): Promise<Record<string, any>>; getMany(input?: { limit?: number; cursor?: string; }): Promise<{ items: Record<string, any>[]; cursor: string | undefined; }>; remove(hashKey: string): Promise<void>; create(item: any): Promise<any>; update(item: any): Promise<Record<string, any>>; private buildUpdateCommandInput; private validateRequiredProperties; } export default KeyValueRepository;