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

Method put

crates/openshell-server/src/persistence/sqlite.rs:83–113  ·  view source on GitHub ↗
(
        &self,
        object_type: &str,
        id: &str,
        name: &str,
        payload: &[u8],
        labels: Option<&str>,
    )

Source from the content-addressed store, hash-verified

81 }
82
83 pub async fn put(
84 &self,
85 object_type: &str,
86 id: &str,
87 name: &str,
88 payload: &[u8],
89 labels: Option<&str>,
90 ) -> PersistenceResult<()> {
91 let now_ms = current_time_ms();
92
93 sqlx::query(
94 r#"
95INSERT INTO "objects" ("object_type", "id", "name", "payload", "created_at_ms", "updated_at_ms", "labels")
96VALUES (?1, ?2, ?3, ?4, ?5, ?5, ?6)
97ON CONFLICT ("object_type", "name") WHERE "name" IS NOT NULL DO UPDATE SET
98 "payload" = excluded."payload",
99 "updated_at_ms" = excluded."updated_at_ms",
100 "labels" = excluded."labels"
101"#,
102 )
103 .bind(object_type)
104 .bind(id)
105 .bind(name)
106 .bind(payload)
107 .bind(now_ms)
108 .bind(labels.unwrap_or("{}"))
109 .execute(&self.pool)
110 .await
111 .map_err(|e| map_db_error(&e))?;
112 Ok(())
113 }
114
115 pub async fn put_if(
116 &self,

Callers

nothing calls this directly

Calls 2

map_db_errorFunction · 0.85
current_time_msFunction · 0.70

Tested by

no test coverage detected