Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mikro-orm): provide the ability to avoid an explicit transaction #1997

Conversation

derevnjuk
Copy link
Contributor

@derevnjuk derevnjuk commented Jul 21, 2022

Information

Type Breaking change
Feature No

In some cases, you might need to avoid an explicit transaction, but preserve an async context to prevent the usage of the global identity map. For example, starting with v3.4, the MongoDB driver supports transactions. Yet, you have to use a replica set, otherwise, the driver will raise an exception.

Usage example

To prevent @Transactional() use of an explicit transaction, you just need to set the disabled field to true:

@Post("/")
@Transactional({disabled: true})
create(@BodyParams() user: User): Promise<User> {
  return this.usersService.create(user);
}

You can also set the flushing strategy for the transaction by setting the flushMode:

@Post("/")
@Transactional({flushMode: FlushMode.AUTO})
create(@BodyParams() user: User): Promise<User> {
  return this.usersService.create(user);
}

Todos

  • Tests
  • Coverage
  • Example
  • Documentation

closes #1996

@derevnjuk derevnjuk self-assigned this Jul 21, 2022
@derevnjuk derevnjuk requested a review from Romakita July 21, 2022 17:00
@derevnjuk derevnjuk changed the title feat(mikro-orm): provide the ability to use the implicit transaction feat(mikro-orm): provide the ability to avoid an explicit transaction Jul 21, 2022
@derevnjuk derevnjuk force-pushed the feat_#1996/provide_the_ability_to_use_the_implicit_transaction_within_the_transactional_context branch from 09ccce0 to b435bb4 Compare July 21, 2022 17:05
@Romakita
Copy link
Collaborator

Perfect :) @derevnjuk

You can click on merge button when you are ready ;)

See you :D

@coveralls
Copy link

coveralls commented Jul 21, 2022

Pull Request Test Coverage Report for Build 2714197662

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.769%

Totals Coverage Status
Change from base Build 2710793819: 0.0%
Covered Lines: 3584
Relevant Lines: 3725

💛 - Coveralls

@derevnjuk derevnjuk merged commit b215ac2 into tsedio:production Jul 21, 2022
@derevnjuk derevnjuk deleted the feat_#1996/provide_the_ability_to_use_the_implicit_transaction_within_the_transactional_context branch July 21, 2022 19:32
@Romakita
Copy link
Collaborator

🎉 This PR is included in version 6.118.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Romakita
Copy link
Collaborator

🎉 This PR is included in version 7.0.0-beta.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

@coveralls
Copy link

coveralls commented Oct 15, 2024

Pull Request Test Coverage Report for Build 2713456200

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.769%

Totals Coverage Status
Change from base Build 2710793819: 0.0%
Covered Lines: 3584
Relevant Lines: 3725

💛 - Coveralls

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

Successfully merging this pull request may close these issues.

[FEAT] Provide the ability to avoid an explicit transaction within the context
3 participants