In Node.js, Nymph supports nested transactions. Nothing will be written to the database's permanent storage until the highest level transaction is committed. When you start a transaction, you give it a name, then you can commit or roll back that transaction, by name. This means if you're doing transactions recursively, you should use a counter in your name. Nymph uses internal transactions that start with the "nymph-" prefix. You should be sure to commit or rollback transactions in the reverse order that they were started, or you might run into trouble.
Nymph has the following methods for managing transactions.
startTransaction- Start a named transaction.
commit- Commit a named transaction.
rollback- Rollback a named transaction.
inTransaction- Check if Nymph is currently running within a transaction.
startTransaction will return a new instance of Nymph. For the rest
of the transaction, until it is committed or rolled back, you should use this
instance. It will be tied to a specific connection to the database.
Not all databases that Nymph supports (namely, MySQL with an engine that doesn't support transactions, like the MyISAM engine) can use transactions. To ensure data consistency, it's highly recommended to use a configuration that supports transactions.