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,
)
| 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 | /// |
no test coverage detected