Skip to content

Commit

Permalink
improve: distinct_string change from hashset to vec
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen committed Mar 11, 2024
1 parent a1ef057 commit ea37ea9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rs/packages/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ pub trait Model: Sized + Unpin + Send + Sync + Serialize + DeserializeOwned {
async fn distinct_string(
key: &str,
filter: impl Into<Option<Document>> + Send,
) -> MongoResult<HashSet<String>> {
) -> MongoResult<Vec<String>> {
let items = Self::cl().distinct(key, filter, None).await?;
let set = items
.into_iter()
.filter_map(|s| match s {
Bson::String(s) => Some(s),
_ => None,
})
.collect::<HashSet<String>>();
.collect();

Ok(set)
}
Expand All @@ -148,7 +148,7 @@ pub trait Model: Sized + Unpin + Send + Sync + Serialize + DeserializeOwned {
key: &str,
filter: impl Into<Option<Document>> + Send,
session: &mut ClientSession,
) -> MongoResult<HashSet<String>> {
) -> MongoResult<Vec<String>> {
let items = Self::cl()
.distinct_with_session(key, filter, None, session)
.await?;
Expand All @@ -158,7 +158,7 @@ pub trait Model: Sized + Unpin + Send + Sync + Serialize + DeserializeOwned {
Bson::String(s) => Some(s),
_ => None,
})
.collect::<HashSet<String>>();
.collect();

Ok(set)
}
Expand Down

0 comments on commit ea37ea9

Please sign in to comment.