Closed Llorx closed 2 years ago
That's the way transaction
works since operating without rollbacks is a little faster default, but if you want (asynchronous) transactions to be abortable, just explicitly use childTransaction
instead of a transaction
. I tried with your code, and it works as you expect, rolling back the puts, so the subsequent get returns undefined:
https://github.com/DoctorEvidence/lmdb-js#dbchildtransactioncallback-function-promise
Ohh I see. Thank you. The worse part is I've read about them, but my brain didn't click...
Hi,
I've been working with transactions. In other databases (MongoDB for example), if you throw an error inside a transaction, the transaction is not commited, so doing some puts and gets will not update the database if you later notice a problem in the values.
Here, if I throw an error, the transaction captures the error and rejects its own promise, but further readings to the database includes the put data, like so:
Here, I expected the second transaction not reading the "test5000" value, as the transaction before was "errored", but it actually reads it. Is that what I should expect or is a bug?
If that's correct, how can I actually block the transaction from commiting?