Class SimpleTransaction

Transaction for simple stores.

  • SimpleSyncStore
  • SimpleAsyncStore

Hierarchy (view full)

Constructors

Properties

done: boolean = false

Whether the transaction was committed or aborted

modifiedKeys: Set<bigint> = ...

List of keys modified in this transaction, if any.

originalData: Map<bigint, void | Uint8Array> = ...

Stores data in the keys we modify prior to modifying them. Allows us to roll back commits.

Methods

  • Retrieves data. Throws an error if an error occurs or if the key does not exist.

    Parameters

    • id: bigint

      The key to look under for data.

    Returns Uint8Array

    The data stored under the key, or undefined if not present.

  • Marks ino as modified, and stashes its value if it has not been stashed already.

    Parameters

    • id: bigint

    Returns void

  • Adds the data to the store under an id. Overwrites any existing data.

    Parameters

    • id: bigint

      The key to add the data under.

    • data: Uint8Array

      The data to add to the store.

    Returns Promise<void>

  • Stashes given key value pair into originalData if it doesn't already exist. Allows us to stash values the program is requesting anyway to prevent needless get requests if the program modifies the data later on during the transaction.

    Parameters

    • id: bigint
    • Optionalvalue: Uint8Array

    Returns void