Skip to content

DynamoDbRepository

Defined in: dynamodb/src/lib/dynamodb-repository.ts:30

T extends Record<string, unknown>

D = Partial<T>

new DynamoDbRepository<T, D>(app): DynamoDbRepository<T, D>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:80

MantleApplication

DynamoDbRepository<T, D>

protected optional _txItems?: TransactWriteItem[]

Defined in: dynamodb/src/lib/dynamodb-repository.ts:78

Buffered write operations when running inside withTransaction().


protected readonly client: DynamoDBClient

Defined in: dynamodb/src/lib/dynamodb-repository.ts:33


readonly createdAtField: string = "createdAt"

Defined in: dynamodb/src/lib/dynamodb-repository.ts:59

Attribute written for auto-managed creation timestamps.

"createdAt"

readonly fieldMap: Record<string, string> = {}

Defined in: dynamodb/src/lib/dynamodb-repository.ts:68

Entity-field-to-attribute overrides, for a table whose attribute names don’t match the entity (e.g. a brownfield table using snake_case). Applies to every field, including partitionKey/sortKey — they are ordinary attributes in DynamoDB.

{}

optional lastKey?: Record<string, AttributeValue>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:75

The LastEvaluatedKey from the most recent paginated findAll() call. Use as _startKey on the next call.


readonly partitionKey: string = "id"

Defined in: dynamodb/src/lib/dynamodb-repository.ts:42

The partition key attribute name for the table.

"id"

readonly optional sortKey?: string

Defined in: dynamodb/src/lib/dynamodb-repository.ts:49

Optional sort key attribute name. When set, findById expects a composite key object { pk: partitionValue, sk: sortValue } and Query is used instead of GetItem.


abstract readonly tableName: string

Defined in: dynamodb/src/lib/dynamodb-repository.ts:36

DynamoDB table name.


readonly timestamps: boolean = true

Defined in: dynamodb/src/lib/dynamodb-repository.ts:56

When true, save / saveAll / updateById / patchById automatically write createdAt and updatedAt ISO-8601 timestamps.

true

readonly updatedAtField: string = "updatedAt"

Defined in: dynamodb/src/lib/dynamodb-repository.ts:61

Attribute written for auto-managed update timestamps.

"updatedAt"

protected buildKey(id): Record<string, AttributeValue>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:125

Build a consistent key map for GetItem / DeleteItem / UpdateItem.

Id

Record<string, AttributeValue>


count(params?): Promise<number>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:663

QueryParams

Promise<number>

Repository.count


deleteById(id): Promise<T>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:624

Id

Promise<T>

Repository.deleteById


describe(): RepositoryCapabilities

Defined in: dynamodb/src/lib/dynamodb-repository.ts:139

Optional capability introspection. All

RepositoryCapabilities

adapters implement it; user repositories may omit it.

Repository.describe


findAll(params?): Promise<T[]>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:154

DynamoQueryParams

Promise<T[]>

Repository.findAll


findById(id): Promise<T | null>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:409

Id

Promise<T | null>

Repository.findById


findPage(params?): Promise<CursorPage<T>>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:181

Fetch one page of results using native DynamoDB cursor pagination. The returned cursor is the LastEvaluatedKey encoded as base64 JSON — pass it back as params.cursor for the next page. Stateless: unlike lastKey, nothing is stored on the repository instance.

Uses Query when a sort key is defined and the where clause pins the partition key, otherwise Scan. skip and sort are rejected — offsets and cross-page ordering don’t compose with cursors.

QueryParams & object

Promise<CursorPage<T>>

Repository.findPage


protected fromItem(item): T

Defined in: dynamodb/src/lib/dynamodb-repository.ts:119

Unmarshall a DynamoDB attribute map to a plain object.

Record<string, AttributeValue>

T


patchById(id, data): Promise<T>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:553

Id

D

Promise<T>

Repository.patchById


save(data): Promise<T>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:423

D

Promise<T>

Repository.save


saveAll(data): Promise<T[]>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:444

D[]

Promise<T[]>

Repository.saveAll


protected toEntityField(field): string

Defined in: dynamodb/src/lib/dynamodb-repository.ts:103

Translates an attribute name back to its entity field name — the inverse of toField.

string

string


protected toField(field): string

Defined in: dynamodb/src/lib/dynamodb-repository.ts:98

Translates an entity field name to its attribute name (fieldMap override, else identity).

string

string


protected toItem(data): Record<string, AttributeValue>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:109

Marshall a plain object to DynamoDB attribute values, omitting undefined/null keys.

Record<string, unknown>

Record<string, AttributeValue>


updateById(id, data): Promise<T>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:483

Id

D

Promise<T>

Repository.updateById


withTransaction<R>(callback): Promise<R>

Defined in: dynamodb/src/lib/dynamodb-repository.ts:713

Execute a set of repository write operations atomically via DynamoDB TransactWriteItems. Supports up to 100 write operations per transaction.

Note: in transaction mode, mutation methods (save, updateById, patchById, deleteById) return the input data immediately rather than the persisted item, since TransactWriteItems does not support ReturnValues.

R

(repo) => Promise<R>

Promise<R>


protected wrapError(err): Error

Defined in: dynamodb/src/lib/dynamodb-repository.ts:743

unknown

Error