Unit of Work in JavaScript

I'm developing a blog system and at this point, I need to do three (or more) SQL update/inserts in a Atomic operation. If one of insert or update operations has failed, all other operations also should be failed (or rollbacked)

I think the Unit Of Work pattern is the best choice for doing this job (am I right?). So, I need to implement the Unit of Work pattern in JavaScript. How can I do this?

I don't really know about Node.JS, but I do know that when using MySQL, if the table is using the InnoDB engine, then you can start with a START TRANSACTION query. Then perform your operations. At any point, you can ROLLBACK to cancel changes. At the end of your code, don't forget to run a COMMIT query, otherwise your changes will automatically roll back.

Hope this helps!