UNPKG

dynabridge

Version:

Simple and light-weight TypeScript entity-focused wrapper for DynamoDB

48 lines (47 loc) 1.82 kB
import { ReturnValuesOnConditionCheckFailure } from '@aws-sdk/client-dynamodb'; import { NativeAttributeValue } from '@aws-sdk/lib-dynamodb'; import { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb/dist-types/DynamoDBClient'; import { DynaBridgeEntity, EntityCommands, Serializer } from './types.js'; declare class DynaBridge<T extends Record<string, DynaBridgeEntity>> { entities: EntityCommands<T>; private readonly _entityTypes; private readonly ddbClient; private readonly serializer; constructor(entities: T, serializer?: Serializer, config?: DynamoDBClientConfig); transaction(operations: { [K in keyof T]: { action: 'Put'; type: K; entity: T[K] extends DynaBridgeEntity<infer U> ? U : never; } | { action: 'Update'; type: K; entity: T[K] extends DynaBridgeEntity<infer U> ? U : never; updateExpression: string; conditionExpression?: string; expressionAttributeNames?: Record<string, string>; expressionAttributeValues?: Record<string, NativeAttributeValue>; returnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure; } | { action: 'Delete'; type: K; entity: T[K] extends DynaBridgeEntity<infer U> ? U : never; }; }[keyof T][]): Promise<void>; private _findById; private _findByIds; private _findAll; private _queryIndex; private _queryTable; private _save; private _saveBatch; private _delete; private _deleteBatch; private _deleteById; private _deleteByIds; private _migrate; private _createKey; private _getKeyFromEntity; private _buildQueryParams; } export { DynaBridge, DynaBridgeEntity, Serializer };