PersistedWrite
PersistedWrite<
TEntity,TConstraint>(options?): <TResult>(target,key,descriptor) =>void
Defined in: packages/ddd-core/persistence/decorators/persisted-write.decorator.ts:76
Applies the canonical persistence write lifecycle to a repository method whose first argument is the aggregate being written.
Equivalent to stacking, outermost to innermost:
@Cache(options.cache) → @AcknowledgePersisted(...) →
@MapPersistenceErrors(...), each selecting the first argument.
- A rejected write translates known constraint errors, leaves the persisted version baseline unchanged and performs no cache maintenance.
- A resolved write acknowledges the persisted version first, then runs best-effort cache maintenance.
It provides no transaction or event-delivery guarantee beyond those decorators: promise resolution must mean a durable autocommitted write. Use the individual decorators for other signatures, for writes that must not acknowledge (such as deletes), or for caller-owned ordering.
Type Parameters
Section titled “Type Parameters”TEntity
Section titled “TEntity”TEntity extends PersistedAggregate
TConstraint
Section titled “TConstraint”TConstraint extends string = never
Parameters
Section titled “Parameters”options?
Section titled “options?”PersistedWriteOptions<TEntity, TConstraint> = {}
Returns
Section titled “Returns”<TResult>(target, key, descriptor) => void
Example
Section titled “Example”@PersistedWrite<User>({ cache: { setKey: (user) => cacheKey(User.aggregateName, { id: user.id }), invalidateKeys: (user) => [ cacheKey(User.aggregateName, { email: user.email }), ], }, unique: { email: (user) => new UniqueEmailException(user) },})async save(user: User): Promise<UserSnapshot> { ... }