Skip to content

Commit

Permalink
feat: to keys" (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Apr 7, 2023
1 parent 12a1ddf commit dd98b50
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions grovedb/src/query_result_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ impl QueryResultElements {
.collect()
}

/// To keys
pub fn to_keys(self) -> Vec<Key> {
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<Vec<u8>, Element> {
self.elements
Expand Down

0 comments on commit dd98b50

Please sign in to comment.