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

Method get_by_name

crates/openshell-server/src/persistence/postgres.rs:305–324  ·  view source on GitHub ↗
(
        &self,
        object_type: &str,
        name: &str,
    )

Source from the content-addressed store, hash-verified

303 }
304
305 pub async fn get_by_name(
306 &self,
307 object_type: &str,
308 name: &str,
309 ) -> PersistenceResult<Option<ObjectRecord>> {
310 let row = sqlx::query(
311 r"
312SELECT object_type, id, name, payload, created_at_ms, updated_at_ms, labels, resource_version
313FROM objects
314WHERE object_type = $1 AND name = $2
315",
316 )
317 .bind(object_type)
318 .bind(name)
319 .fetch_optional(&self.pool)
320 .await
321 .map_err(|e| map_db_error(&e))?;
322
323 Ok(row.map(row_to_object_record))
324 }
325
326 pub async fn delete(&self, object_type: &str, id: &str) -> PersistenceResult<bool> {
327 let result = sqlx::query("DELETE FROM objects WHERE object_type = $1 AND id = $2")

Callers

nothing calls this directly

Calls 1

map_db_errorFunction · 0.85

Tested by

no test coverage detected