zibri
    Preparing search index...

    Class ChangeSetRepository<T, CreateData, UpdateData>

    A base repository that automatically handles creation of change sets.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    • Finds a single entity with the given options.

      Type Parameters

      • B extends boolean = true

      Parameters

      • options: FindOneOptions<T>

        The options, including the where filter etc.

      • required: B = ...

        Whether or not a result is required. Defaults to true.

      Returns Promise<B extends false ? T | undefined : T>

      The found result. If required is set to false, also undefined.

    • Resets the changes of a single change set on the given entity to the state before the change set. This DOES preserve any changes that happened after the change set. The given change set gets deleted afterwards.

      Parameters

      • entity: T

        The entity that should be reset.

      • changeSetId: string

        The id of the changeSet to reset.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<ResetChangeSetResult<T>>

      The updated entity.

    • Resets the changes of a single change set on the entity with the given id to the state before the oldest change set. This DOES preserve any changes that happened after the change set. The given change set gets deleted afterwards.

      Parameters

      • id: T["id"]

        The id of the entity that should be reset.

      • changeSetId: string

        The id of the changeSet to reset.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<ResetChangeSetResult<T>>

      The updated entity.

    • Rolls back all changes on the entities found with the given where filter to the state of the given timestamp. This DOES NOT preserve any changes that happened after the timestamp. Any change sets after the given timestamp will be deleted in the end.

      Parameters

      • timestampInNs: bigint

        The timestamp to which the rollback should happen with nanosecond precision.

      • Optionalwhere: Where<T>

        A filter to only rollback some entities.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<number>

      The updated entity.

    • Rolls back all changes on the given entity that have happened since the given change set. This DOES NOT preserve any changes that happened after the change set. The given change set and any change sets after that will be deleted in the end. Calls rollbackToTimestamp on the change set timestamp internally.

      Parameters

      • entity: T

        The entity to rollback.

      • changeSetId: string

        The id of the changeSet to rollback to.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<T>

      The updated entity.

    • Rolls back all changes on the entity with the given id that have happened since the given change set. This DOES NOT preserve any changes that happened after the change set. The given change set and any change sets after that will be deleted in the end. Calls rollbackToTimestampById on the change set timestamp internally.

      Parameters

      • id: T["id"]

        The id of the entity to rollback.

      • changeSetId: string

        The id of the changeSet to rollback to.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<T>

      The updated entity.

    • Rolls back all changes on the given entity that have happened since the given timestamp. This DOES NOT preserve any changes that happened after the timestamp. Any change sets after the given timestamp will be deleted in the end.

      Parameters

      • entity: T

        The entity to rollback.

      • timestampInNs: bigint

        The timestamp to which the rollback should happen with nanosecond precision.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<T>

      The updated entity.

    • Rolls back all changes on the entity with the given id that have happened since the given timestamp. This DOES NOT preserve any changes that happened after the timestamp. Any change sets after the given timestamp will be deleted in the end.

      Parameters

      • id: T["id"]

        The id of the entity to rollback.

      • timestampInNs: bigint

        The timestamp to which the rollback should happen with nanosecond precision.

      • createChangeSet: boolean = true

        Whether or not a change set should be created.

      • preserveCreateChangeSet: boolean = true

        Whether or not create change sets should be preserved. In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.

      • Optionaloptions: BaseRepositoryOptions

        Additional options, eg. Transaction.

      Returns Promise<T>

      The updated entity.