How does nodejs deal with data loss caused by sudden server shutdown and restart

A nodejs is running when suddenly the server shuts down and restarts. Maybe nodejs is doing some query and insertion work at this time.
this can lead to interruptions, often causing errors. Similar to transactional.
will you consider this situation when you write programs? Still, my worries are superfluous. after all, it is rare for the server to shut down suddenly.
because I find it troublesome to deal with.

Apr.09,2021

this is the need for data persistence.

it may be better for the transaction to be taken over by the transaction of the database. Of course, it is no problem if you implement it in code yourself, just note that the lock of the transaction should also be persisted

Menu