Skip to content

Can someone explain when exactly implicit transactions occur? #5466

Answered by B4nan
ersinakinci asked this question in Q&A
Discussion options

You must be logged in to vote

em.create is sync method, it does the same as your previous example - create entity instance (via constructor) and persist it. its the flush call that does things (and you need to await that one instead of the create call). that's described here

Likewise, using .find seems to instantly retrieve records--are those statements wrapped inside of a transaction?

Nope, you need explicit transaction demarcation for that.

https://mikro-orm.io/docs/transactions#approach-2-explicitly

With that approach, you no longer need the explicit flush, as it is called automatically after the callback (as well as via explicit em.commit()).

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ersinakinci
Comment options

@B4nan
Comment options

@ersinakinci
Comment options

Answer selected by ersinakinci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants