Class ChangeSetRepository<T, CreateData, UpdateData>

A base repository that automatically handles creation of change sets.

Type Parameters

Hierarchy (View Summary)

Constructors

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 ? undefined | T : 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 date. This DOES NOT preserve any changes that happened after the date. Any change sets after the given date will be deleted in the end.

    Parameters

    • date: Date

      The date to which the rollback should happen.

    • 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 rollbackByDate on the change set date 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 rollbackByDate on the change set date 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 date. This DOES NOT preserve any changes that happened after the date. Any change sets after the given date will be deleted in the end.

    Parameters

    • entity: T

      The entity to rollback.

    • date: Date

      The date to which the rollback should happen.

    • 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 date. This DOES NOT preserve any changes that happened after the date. Any change sets after the given date will be deleted in the end.

    Parameters

    • id: T["id"]

      The id of the entity to rollback.

    • date: Date

      The date to which the rollback should happen.

    • 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.