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

Method put_scoped

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

Source from the content-addressed store, hash-verified

262 }
263
264 pub async fn put_scoped(
265 &self,
266 object_type: &str,
267 id: &str,
268 name: &str,
269 scope: &str,
270 payload: &[u8],
271 labels: Option<&str>,
272 ) -> PersistenceResult<()> {
273 let now_ms = current_time_ms();
274
275 sqlx::query(
276 r#"
277INSERT INTO "objects" ("object_type", "id", "name", "scope", "payload", "created_at_ms", "updated_at_ms", "labels", "resource_version")
278VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?6, ?7, 1)
279ON CONFLICT ("object_type", "name") WHERE "name" IS NOT NULL DO UPDATE SET
280 "scope" = excluded."scope",
281 "payload" = excluded."payload",
282 "updated_at_ms" = excluded."updated_at_ms",
283 "labels" = excluded."labels",
284 "resource_version" = "objects"."resource_version" + 1
285"#,
286 )
287 .bind(object_type)
288 .bind(id)
289 .bind(name)
290 .bind(scope)
291 .bind(payload)
292 .bind(now_ms)
293 .bind(labels.unwrap_or("{}"))
294 .execute(&self.pool)
295 .await
296 .map_err(|e| map_db_error(&e))?;
297 Ok(())
298 }
299
300 pub async fn get(
301 &self,

Callers

nothing calls this directly

Calls 2

map_db_errorFunction · 0.85
current_time_msFunction · 0.70

Tested by

no test coverage detected