Hive: Get List of Keys in a box

Created on 1 Feb 2020  路  3Comments  路  Source: hivedb/hive

Hi
How could I get all the keys in a box and change all of them to a specific value?
if I want to delete all keys in a box, better to delete the box or find each key and delete it?
how could I delete or empty a box?

question

All 3 comments

1) box.keys. You cannot change a key, you have to delete / add

2) box.deleteFromDisk()

@MoacirSchmidt
Thanks, Will be very good if these added to Docs
Q: how could I convert _KeyIterable from box.keys to a List?
I use This

 List<String> dbKeys = [];
  box.keys.toString().replaceAll(new RegExp(r"([() ]+)"), '').split(',').forEach((key) {
    dbKeys.add(key);
  });

if I want to delete all keys in a box, better to delete the box or find each key and delete it?

You should use box.clear().

how could I convert _KeyIterable to a List

box.keys returns an Iterable<dynamic>. If you want this iterable to be a list, just use box.keys.toList().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rupamking1 picture rupamking1  路  3Comments

yannickvg picture yannickvg  路  4Comments

kaboc picture kaboc  路  3Comments

jamesdixon picture jamesdixon  路  3Comments

abacaj picture abacaj  路  3Comments