Not currently. What would you need transactions for?
If you want to write multiple entries with a single disk access, you can use putAll().
If putAll() fails, are all the kv pairs not written?
Yes exactly
Thanks @leisim
Hi @leisim ,
Do you plan to implement a "transaction" on multiples boxes ? I would like to save a complete set of data, or nothing.
Here is an example for an invoice and its lines/products :
Hive.transaction((transaction) {
transaction.add(Hive.box('invoices').add(invoiceId, invoice));
transaction.add(Hive.box('lines').add(lineId, line));
// commit
// rollback in case of error
});
@benoitverstraete
I do but it is not high on the priority list. The next update will improve performance and introduce HiveObjects, ListView and MapView. The update after that will contain queries. Then I plan to look at transactions...
What if you need to do both put() and delete() in a single transaction?
e.g. ToDo app
If you want to delete categoryB at the same time as task3 is moved to categoryA which makes categoryB empty, a series of update and removal operations is probably necessary. The feature of transaction seems useful in such a case.
The feature of transaction seems useful in such a case.
I agree. It's still on my radar...
An additional use case example would be a conditional write (reading value A and only writing value B if A satisfies a certain condition).
@ShangyanLi Why are transactions needed for such an operation? Wouldn't it be possible to implement this with the operations currently available?
Most helpful comment
I agree. It's still on my radar...