MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / delete_if

Method delete_if

crates/openshell-server/src/persistence/sqlite.rs:231–262  ·  view source on GitHub ↗
(
        &self,
        object_type: &str,
        id: &str,
        expected_resource_version: u64,
    )

Source from the content-addressed store, hash-verified

229 }
230
231 pub async fn delete_if(
232 &self,
233 object_type: &str,
234 id: &str,
235 expected_resource_version: u64,
236 ) -> PersistenceResult<bool> {
237 let result = sqlx::query(
238 r#"
239DELETE FROM "objects"
240WHERE "object_type" = ?1 AND "id" = ?2 AND "resource_version" = ?3
241"#,
242 )
243 .bind(object_type)
244 .bind(id)
245 .bind(i64::try_from(expected_resource_version).unwrap_or(i64::MAX))
246 .execute(&self.pool)
247 .await
248 .map_err(|e| map_db_error(&e))?;
249
250 if result.rows_affected() > 0 {
251 Ok(true)
252 } else {
253 // Check if object exists to distinguish NotFound from Conflict
254 let existing = self.get(object_type, id).await?;
255 if let Some(record) = existing {
256 return Err(PersistenceError::Conflict {
257 current_resource_version: Some(record.resource_version),
258 });
259 }
260 Ok(false)
261 }
262 }
263
264 pub async fn put_scoped(
265 &self,

Callers

nothing calls this directly

Calls 2

map_db_errorFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected