diff --git a/shard.yml b/shard.yml index 43fbac1..124b49b 100644 --- a/shard.yml +++ b/shard.yml @@ -1,8 +1,9 @@ name: dodb -version: 0.2.1 +version: 0.2.2 authors: - Luka Vandervelden + - Philippe Pittoli description: | Simple, embeddable Document-Oriented DataBase in Crystal. diff --git a/src/dodb/index.cr b/src/dodb/index.cr index 5e5bb9e..962d69b 100644 --- a/src/dodb/index.cr +++ b/src/dodb/index.cr @@ -87,6 +87,12 @@ class DODB::Index(V) < DODB::Indexer(V) {value, key} end + # in case new_value hasn't change its index + def update(new_value : V) + index = key_proc.call new_value + update index, new_value + end + def update(index : String, new_value : V) _, key = get_with_key index