IWriteSideAggregateRepository
Defined in: packages/ddd-core/application/ports/write-side-aggregate-repository.port.ts:27
Write-side repository contract for commands that mutate an existing aggregate.
findById() must read authoritative persistence and must not use a read-side
result cache. Adapters backed by an ORM identity map should force a refresh so
optimistic-concurrency checks are based on current persisted state.
Use this contract in update/delete command handlers that must authorize and mutate the real aggregate before saving it.
Example
Section titled “Example”const user = await repository.findById(command.id);if (!user) throw new EntityNotFoundException('User', command.id);authorizer.authorize('update', user);user.update({ department: command.department });await repository.save(user);Extends
Section titled “Extends”ICommandRepository<TEntity,unknown>
Type Parameters
Section titled “Type Parameters”TEntity
Section titled “TEntity”TEntity
Rehydrated aggregate type.
TId = string
Aggregate identifier type.
Methods
Section titled “Methods”findById()
Section titled “findById()”findById(
id):Promise<TEntity|null>
Defined in: packages/ddd-core/application/ports/write-side-aggregate-repository.port.ts:35
Loads the current authoritative aggregate for a mutating command.
Parameters
Section titled “Parameters”TId
Aggregate identifier.
Returns
Section titled “Returns”Promise<TEntity | null>
The rehydrated aggregate, or null when it does not exist.
save()
Section titled “save()”save(
entity):Promise<unknown>
Defined in: packages/ddd-core/application/ports/command-repository.port.ts:28
Persists the aggregate/payload.
Returning null is the conventional deletion result used by the DDD cache
decorator to trigger eviction/barrier behavior.
Parameters
Section titled “Parameters”entity
Section titled “entity”TEntity
Returns
Section titled “Returns”Promise<unknown>