Skip to content

Add UUID built-in convenience type to SpacetimeDB #3290

@cloutiertyler

Description

@cloutiertyler
use spacetimedb::Uuid;

#[table(name = foobar)]
struct Foobar {
    uuid: Uuid,
}

#[reducer]
fn baz(ctx: &ReducerContext) {
    ctx.db.foobar.insert(Foobar {
        uuid: ctx.uuidv7(),
    });
}
using SpacetimeDB; // hypothetical namespace for Uuid, reducer, etc.

[Table("foobar")]
public class Foobar
{
    public Uuid Uuid { get; set; }
}

public static class Module
{
    [Reducer("baz")]
    public static void Baz(ReducerContext ctx)
    {
        ctx.Db.Foobar.Insert(new Foobar
        {
            Uuid = ctx.Uuidv7()
        });
    }
}
import { Uuid, table, reducer, ReducerContext } from "spacetimedb";

interface Foobar {
  uuid: Uuid;
}

table("foobar", {
  uuid: "uuid",
});

reducer("baz", (ctx: ReducerContext) => {
  ctx.db.foobar.insert({
    uuid: ctx.uuidv7(),
  } as Foobar);
});

See also:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions