Index#update_or_create(key, value) added.

remotes/1708105384931250775/master
Luka Vandervelden 2020-02-02 14:18:03 +01:00
parent eb50b5c433
commit 355f85d635
1 changed files with 6 additions and 0 deletions

View File

@ -93,6 +93,12 @@ class DODB::Index(V) < DODB::Indexer(V)
@storage[key] = new_value
end
def update_or_create(index : String, new_value : V)
update index, new_value
rescue MissingEntry
@storage << new_value
end
def delete(index : String)
key = get_key index