Im truing to use the .distinct
method to get all ‘_ids’ in the collection. The .distinct
method returns a Vec<Bson, Global> and I would live to convert that to a Vec for exemple.
I tried everything I could but can figure this one out.
This is what I have now:
let clients_ids = self
.get_clients_collection()
.distinct("_id", None, None)
.await
.map_err(MongoQueryError)?;
Should I iterate over each item in the Vec and convert them individualy to String?
In that cause how can I do that?
for item in &clients_ids {
println!("Bson Item {:?}", item); // prints ObjectId("61842402bcfb83e1b27b6d85")
}
Thanks you all in advance.