From 7272b9fe6f856f33d7500199777ea481d4ea8460 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Wed, 22 May 2024 05:34:36 +0200 Subject: [PATCH] Partitions gets a new `get_with_keys?` function, for consistency. --- src/dodb/partition.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dodb/partition.cr b/src/dodb/partition.cr index a7352ed..a640f5a 100644 --- a/src/dodb/partition.cr +++ b/src/dodb/partition.cr @@ -137,6 +137,14 @@ class DODB::Partition(V) < DODB::Indexer(V) r_value end + # Safe version of `#get_with_keys`. + # NOTE: returns an empty list on empty or non-existing partition. + def get_with_keys?(partition : String) : Array(Tuple(V, Int32)) + get_with_keys partition + rescue MissingEntry + Array(Tuple(V, Int32)).new + end + # Deletes all entries within the provided partition. # # ```