MCPcopy Create free account
hub / github.com/Cosmian/kms / retrieve_objects

Method retrieve_objects

crate/server_database/src/core/database_objects.rs:233–255  ·  view source on GitHub ↗

Retrieve objects from the database. The `uid_or_tags` parameter can be either a `uid` or a JSON array of tags. The `user_filter` parameter allows filtering based on user permissions. The `state_filter` parameter allows filtering based on the state of the objects. The `params` parameter allows passing additional parameters for the database query. Returns a `DbResult` containing a `HashMap` whe

(
        &self,
        uid_or_tags: &str,
    )

Source from the content-addressed store, hash-verified

231 ///
232 /// * `DbResult<HashMap<String, ObjectWithMetadata>>` - A result containing a map of `uid`s to `ObjectWithMetadata`.
233 pub async fn retrieve_objects(
234 &self,
235 uid_or_tags: &str,
236 ) -> DbResult<HashMap<String, ObjectWithMetadata>> {
237 Box::pin(self.record("retrieve_objects", async move {
238 let uids = if uid_or_tags.starts_with('[') {
239 // tags
240 let tags: HashSet<String> = serde_json::from_str(uid_or_tags)?;
241 self.list_uids_for_tags(&tags).await?
242 } else {
243 HashSet::from([uid_or_tags.to_owned()])
244 };
245 let mut results: HashMap<String, ObjectWithMetadata> = HashMap::new();
246 for uid in &uids {
247 let owm = self.retrieve_object(uid).await?;
248 if let Some(owm) = owm {
249 results.insert(uid.to_owned(), owm);
250 }
251 }
252 Ok(results)
253 }))
254 .await
255 }
256
257 /// Retrieve a single object from the database.
258 ///

Callers 6

importFunction · 0.80
get_attributesFunction · 0.80

Calls 5

fromFunction · 0.85
recordMethod · 0.80
retrieve_objectMethod · 0.80
list_uids_for_tagsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected