index#update(new_value) : index is automatically retrieved.

remotes/1708105384931250775/master
Philippe PITTOLI 2020-04-19 18:18:53 +02:00
parent 4ba6c26a21
commit e457a80399
2 changed files with 8 additions and 1 deletions

View File

@ -1,8 +1,9 @@
name: dodb
version: 0.2.1
version: 0.2.2
authors:
- Luka Vandervelden <lukc@upyum.com>
- Philippe Pittoli <karchnu@karchnu.fr>
description: |
Simple, embeddable Document-Oriented DataBase in Crystal.

View File

@ -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