How to apply events from eventstore to my db in the same transaction?

after appending the event to the event store, I need to apply that event to my primary db to update the entity’s state synchronously and also in the same transaction and prevent race condition, does the eventstoredb support something like that? or if it doesn’t, do you guys know which technology do it in the same transaction and synchronously and prevent race condition?

please help me, thank you so much

Couple of questions to make sure I undrstand:

after appending the event to the event store, I need to apply that event to my primary db

What do you mean by primary db, what database?
What is the source of the data you’re appending to EventStoreDB ?

and prevent race condition

Race conditions between what part of your application ?

does the eventstoredb support something like that?

EventStoreDB does not support distributed transactions. It is on purpose.
Most applications built on top of it have their transactional & optimist concurrency behavior against a nemed stream , that holds the history of a single entity instance.
All other work is perforformed reactively through the subscription capability of the database.

ESDB aims to be the primary database, everything else is downstream and gets updated asynchronously. You can implement pseudo-synchronous update without using subscriptions, but it will fail one way or another of your other database won’t let you to execute the operation, but you already appended an event.