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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c524-2c331.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c524-2c331.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?