diff --git a/grovedb/src/query_result_type.rs b/grovedb/src/query_result_type.rs index 69c8a774a..b9300d2db 100644 --- a/grovedb/src/query_result_type.rs +++ b/grovedb/src/query_result_type.rs @@ -112,6 +112,22 @@ impl QueryResultElements { .collect() } + /// To keys + pub fn to_keys(self) -> Vec { + self.elements + .into_iter() + .filter_map(|result_item| match result_item { + QueryResultElement::ElementResultItem(_) => None, + QueryResultElement::KeyElementPairResultItem(key_element_pair) => { + Some(key_element_pair.0) + } + QueryResultElement::PathKeyElementTrioResultItem(path_key_element_trio) => { + Some(path_key_element_trio.1) + } + }) + .collect() + } + /// To key elements btree map pub fn to_key_elements_btree_map(self) -> BTreeMap, Element> { self.elements