Function: Version()
Version(
options?):PropertyDecorator
Defined in: src/decorators/Version.ts:27
Property decorator for optimistic concurrency control.
Automatically tracks and validates the version token on UPDATE and DELETE operations.
If another concurrent process has updated the row in the meantime, a DbUpdateConcurrencyException is thrown.
Supported strategies:
'number'(default): Auto-increments integer sequence (1, 2, 3...)'timestamp': Updates with current timestamp'uuid': Generates a new random UUID v4
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | string | VersionOptions | Version strategy and column options. |
Returns
PropertyDecorator
Usecase
Prevent the "lost update" problem in multi-user applications where two users edit the same record simultaneously.
Example
@Version()
version!: number;