MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / add_player

Function add_player

modules/module-test/src/lib.rs:380–389  ·  view source on GitHub ↗
(ctx: &ReducerContext, name: String)

Source from the content-addressed store, hash-verified

378
379#[spacetimedb::reducer]
380pub fn add_player(ctx: &ReducerContext, name: String) -> Result<(), String> {
381 // This always creates a new one because id is auto-incremented.
382 let inserted = ctx.db.test_e().id().try_insert_or_update(TestE { id: 0, name })?;
383
384 // Since the previous one is always inserted, at this point it's always updated by this function.
385 // This is a no-op, but we can still call it.
386 ctx.db.test_e().id().try_insert_or_update(inserted)?;
387
388 Ok(())
389}
390
391#[spacetimedb::reducer]
392pub fn delete_player(ctx: &ReducerContext, id: u64) -> Result<(), String> {

Callers

nothing calls this directly

Calls 3

OkFunction · 0.50
try_insert_or_updateMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…