Skip to content

Support for DisposableStack and AsyncDisposableStack #1828

Description

@tracker1

I would suggest implementing both dispose and disposeAsync for connection and transaction objects, then update the documentation to await using statements.

{
  await using cn = await pool.connect();
  // release to pool when falling out of scope
}

// or
{
  await using tx = pool.transaction();
  await tx.begin()
  ...
  // explicitly commit
  await tx.commit();

  // implicitly abort if falls out of scope without a commit
}

refs:

  1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncDisposableStack/disposeAsync
  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DisposableStack/Symbol.dispose

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions