github clockworklabs/SpacetimeDB v0.12.0-beta

10 hours ago

🌟 It's happening! 🌟

We've got a big one for you today! We've been burning the midnight oil to bring you the cream of the SpacetimeDB crop. We are updating and improving our APIs and interfaces across the board in an effort to stabilize and polish them up for a final release!

SpacetimeDB is getting closer and closer to a final 1.0 release and this is a huge milestone on that journey. These new APIs will allow us to implement some amazing new features and vastly improve the user experience of using SpacetimeDB across multiple languages and clients.

Module API

The module API has had it's most major overhaul since the announcement of SpacetimeDB. We're reducing the amount of globals and enforcing accessing the database via a ReducerContext.

Rust

#[reducer]
pub fn add(ctx: &ReducerContext, name: String) {
    println!("Inserting {}", name);
    ctx.db.person().insert(Person { name });
}

CHECK IT OUT! The #[spacetimedb(reducer)] macro has been simplified to just #[reducer]!

C#

[SpacetimeDB.Reducer]
public static void Add(ReducerContext ctx, string name)
{
    Log.Info($"Inserting {name}");
    ctx.Db.Person.Insert(new Person { Name = name });
}

SDK API

The SDKs now share almost exactly the same API as you use to access your data inside your module.

let ctx = DbConnection.builder()
    .with_url("https://testnet.spacetimedb.com")
    .with_module_name("bitcraft")
    .build();
...
for person in ctx.db.person().iter() {
   println!("Hey, {}", person.name);
}

C#

var conn = DbConnection.Builder()
    .WithUri("https://testnet.spacetimedb.com")
    .WithModuleName("bitcraft")
    .Build();
...
foreach (var person in ctx.Db.Person.Iter())
{
    Log.Info($"Hello, {person.Name}!");
}

Now you can write your client code with the same patterns as your server code!

Migration Guide

Check out our full migration guide to update your code for v0.12 available in the docs section of our website.

CLI updates 🖊️

We've updated a lot of the args to the CLI to be more clear and consistent. If something gives you an errors, check --help to see if it's changed.
Some of the important changes:

  • spacetime local clear (to delete all local server data) is now called spacetime server clear
  • spacetime build --skip_clippy/-S is now more explicitly --skip-println-checks
  • spacetime logs database 10 is now spacetime logs database -n 10
  • spacetime publish and spacetime generate now accept a --build-options param, e.g. spacetime publish --build-options="--debug --skip-println-checks"

Small clarity changes:

  • All --anon-identity parameters have been renamed to --anonymous
  • spacetime energy status is now spacetime energy balance for clarity
  • spacetime publish --clear-database has been renamed to spacetime publish --delete-data for clarity
  • spacetime subscribe -n now has a longform option --num-updates
  • spacetime publish|generate --wasm-file -> spacetime publish|generate --bin-path

What's Changed (It's... uhh a lot)

Full Changelog: v0.11.1-beta...v0.12.0-beta

Don't miss a new SpacetimeDB release

NewReleases is sending notifications on new releases.