objectbox-dart icon indicating copy to clipboard operation
objectbox-dart copied to clipboard

Delete the store data with single function.

Open raphire08 opened this issue 4 years ago • 4 comments

We have removeAll functionality for the individual boxes. Do we also have something like this for the entire store, such that all the data from all the boxes is deleted?

And if I have to run them in transaction and there are many entities. I am doing it like this now.

 _db.store.runInTransaction(TxMode.write, () {
      _db.store.box<Shape1>().removeAll();
      _db.store.box<Shape2>().removeAll();
    });

Could there be a better way to do this ?

raphire08 avatar Aug 18 '21 06:08 raphire08

BTW: If you didn't want to keep any data, i.e. not even last object IDs (auto-increments), you can delete the database directory. This would also be the fastest thing to do if you want to remove the whole database.

Still, providing store.removeAll() sounds reasonable.

Edit: the Java implementation. Not sure if the C library has a function for this (yet).

vaind avatar Aug 20 '21 16:08 vaind

@raphire08 You're always free to write your own dart extensions for whatever functionality you feel is missing.

Buggaboo avatar Aug 23 '21 08:08 Buggaboo