TransactionGroup is a class that handles the bundling of multiple transactions into a single request. The provider handles the implementation details. If a transaction group is provided to the baseEntity object before either Save() or Delete() is called instead of just immediately executing its SQL or GQL, it provides the instructions to the TransactionGroup object instead.

Then, whenever the TransactionGroup object instance has its Submit() method called, all of the requests will be bundled into a single request and handled. For example in the case of the GraphQLDataProvider, we queue up all of the GQL statements for all of the mutations and send them across as a single GraphQL request. The GraphQL server handles the actual DB transaction stuff.

TransactionGroup will call a callback function, if provided, after the transaction has either completed succesfully or failed. If it is succesful, for Save() method calls, the latest data for that record will be provided back. For Delete() method calls, the callback will be called with no data.

This class is the base class for managing a group of transactions and submitting it to the provider so it can be handled as an ATOMic transaction

Hierarchy

  • TransactionGroupBase

    Constructors

    Properties

    _pendingTransactions: TransactionItem[] = []
    _preprocessingItems: TransactionPreprocessingItem[] = []
    _status: "Pending" | "In Progress" | "Complete" | "Failed" = 'Pending'
    _variables: TransactionVariable[] = []
    transactionNotifier: Subject<{
        error?: any;
        results?: TransactionResult[];
        success: boolean;
    }> = ...

    Type declaration

    Accessors

    Methods

    • This is used by the BaseEntity/Provider objects to manage transactions on your behalf. WARNING: Do NOT directly call this method. Instead set the TransactionGroup property on the

      Parameters

      Returns void

      Base Entity

      class to make an entity object part of a transaction group.

    • Notifies observers about transaction success or failure

      Parameters

      • success: boolean

        Whether the transaction was successful

      • Optional results: TransactionResult[]

        The transaction results (if applicable)

      • Optional error: any

        Any error that occurred (if applicable)

      Returns void

    • Indicates whether all of the entities that have registered with this transaction group have completed their preprocessing

      Returns boolean

    • If an entity object needs to conduct any type of asynchronous preprocessing before a transaction is submitted, it must notify its transaction group that it is doing so with this method. This causes the TransactionGroup to wait for all preprocessing to be completed before submitting the transaction. This method checks to see if an the entity has already been registered for preprocessing and if so, does nothing.

      Parameters

      Returns void

    • This utility method is to be used by sub-classes to set the values of the variables on the BaseEntity objects before the transaction is executed for variables that are defined as 'Use' type. This is used to pass values from one transaction item to another.

      Parameters

      Returns number

      the number of values set on the entity object

    • This utility method is to be used by sub-classes to set the values of the variables on the BaseEntity objects after the transaction is executed for variables

      Parameters

      • entityObject: BaseEntity<unknown>
      • queryResults: any

      Returns number

      the number of variables that had their processed values set from the provided entity object

    • Submits the transaction group to the provider for handling. The provider will handle the actual transaction and call the callback functions

      Parameters

      • allowRetryOfFailedTransaction: boolean = false

        If true, the transaction group will be resubmitted even if it has failed. If false, the transaction group will not be resubmitted if it has failed.

      Returns Promise<boolean>

      true if the transaction was successful, false if it failed. If the method fails, check each of the individual BaseEntity objects within the TransactionGroup for their result histories using BaseEntity.ResultHistory and BaseEntity.LatestResult