Skip to content

Commit

Permalink
feat(pgstac): add delete item (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski authored Dec 4, 2024
1 parent 69439b0 commit 425a4dc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/pgstac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ pub trait Pgstac: GenericClient {
self.void("upsert_items", &[&items]).await
}

/// Deletes an item.
async fn delete_item(&self, id: &str, collection: Option<&str>) -> Result<()> {
self.void("delete_item", &[&id, &collection]).await
}

/// Searches for items.
async fn search(&self, search: Search) -> Result<Page> {
let search = search.into_cql2_json()?;
Expand Down Expand Up @@ -474,6 +479,24 @@ pub(crate) mod tests {
);
}

#[pgstac_test]
async fn delete_item(client: &Transaction<'_>) {
let collection = Collection::new("collection-id", "a description");
client.add_collection(collection).await.unwrap();
let mut item = Item::new("an-id");
item.collection = Some("collection-id".to_string());
item.geometry = Some(longmont());
client.add_item(item.clone()).await.unwrap();
client
.delete_item(&item.id, Some("collection-id"))
.await
.unwrap();
assert_eq!(
client.item("an-id", Some("collection-id")).await.unwrap(),
None,
);
}

#[pgstac_test]
async fn upsert_item(client: &Transaction<'_>) {
let collection = Collection::new("collection-id", "a description");
Expand Down

0 comments on commit 425a4dc

Please sign in to comment.