db // refers to the database outside the transaction
db.$transaction(async (tx) => {
tx // refers to the transaction
db // refers to the database outside the transaction -- probably never actually want to use this
})
After
db // refers to the database outside the transaction
transaction(async () => {
db // refers to the transaction. "other db" is not accessible
});
The nice thing is that you don't need to pass tx through a arguments. It's literally just dynamically scoped.
Before
After
The nice thing is that you don't need to pass
tx
through a arguments. It's literally just dynamically scoped.