From a802e33062a63c433dd673d067e29ed93b355ef5 Mon Sep 17 00:00:00 2001 From: rain Date: Fri, 10 Jul 2026 08:10:50 -0400 Subject: [PATCH 01/20] docs: update delete-data flag examples --- .../00100-intro/00100-getting-started/00500-faq.md | 8 ++++---- .../00300-unity-tutorial/00300-part-2.md | 6 +++--- .../00300-unity-tutorial/00400-part-3.md | 8 ++++---- .../00300-unity-tutorial/00500-part-4.md | 4 ++-- .../00400-unreal-tutorial/00300-part-2.md | 6 +++--- .../00400-unreal-tutorial/00400-part-3.md | 10 +++++----- .../00400-unreal-tutorial/00500-part-4.md | 4 ++-- .../00500-godot-tutorial/00300-part-2.md | 6 +++--- .../00500-godot-tutorial/00400-part-3.md | 8 ++++---- .../00500-godot-tutorial/00500-part-4.md | 4 ++-- .../00100-databases/00300-spacetime-publish.md | 2 +- .../00500-migrations/00200-automatic-migrations.md | 4 ++-- .../00100-how-to/00100-deploy/00100-maincloud.md | 2 +- .../00100-cli-reference/00300-spacetime-json.md | 2 +- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/docs/00100-intro/00100-getting-started/00500-faq.md b/docs/docs/00100-intro/00100-getting-started/00500-faq.md index abbbc177437..b96cd4f2f1f 100644 --- a/docs/docs/00100-intro/00100-getting-started/00500-faq.md +++ b/docs/docs/00100-intro/00100-getting-started/00500-faq.md @@ -221,7 +221,7 @@ conn.subscriptionBuilder().subscribe( ### How do I handle schema migrations? -When you publish an updated module, SpacetimeDB compares the new schema with the existing one and performs automatic migrations for compatible changes (adding tables, adding columns with defaults, etc.). For breaking changes, you may need to publish with `--delete-data` during development. See [Automatic Migrations](../../00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md) for details on what changes are supported. +When you publish an updated module, SpacetimeDB compares the new schema with the existing one and performs automatic migrations for compatible changes (adding tables, adding columns with defaults, etc.). For breaking changes, you may need to publish with `--delete-data=always` during development. See [Automatic Migrations](../../00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md) for details on what changes are supported. ### How do I add a column to an existing table? @@ -261,10 +261,10 @@ Yes. When you `spacetime publish` an update, SpacetimeDB hot-swaps the module co ### How do I clear my database? -Use the `-c` (or `--delete-data`) flag when publishing: +Use the `-c always` (or `--delete-data=always`) option when publishing: ```bash -spacetime publish my-app -c +spacetime publish my-app -c always ``` This deletes all data and re-runs the `init` reducer. @@ -291,7 +291,7 @@ If your module's `init` reducer panics (for example, due to a unique constraint ### How do I reset my database during development? -Use `spacetime publish my-app --delete-data` to clear all data and republish. Or use `spacetime dev`, which handles this automatically with the `--delete-data=on-conflict` flag. +Use `spacetime publish my-app --delete-data=always` to clear all data and republish. Or use `spacetime dev`, which handles this automatically with the `--delete-data=on-conflict` flag. ### I got a weird error when compiling my module! diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md index 033bd7ed2ea..6cf56341ba5 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md @@ -587,7 +587,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -607,7 +607,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -626,7 +626,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md index fc5b6ae572c..570c5a50d0b 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -898,7 +898,7 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md index bfc58fc0ded..bb7fb24b245 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md @@ -522,7 +522,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Regenerate your server bindings with: @@ -861,7 +861,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). You will have to update the database name in `blackholio-server/spacetime.local.json` to match. - Update the URL in the Unity project to: `https://maincloud.spacetimedb.com` - Update the module name in the Unity project to ``. diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md index a592e63bfda..3d43ad8c38b 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md @@ -580,7 +580,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -600,7 +600,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -619,7 +619,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md index 1b388814d96..74d7bba4ced 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -894,13 +894,13 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. :::note -When using `--delete-data`, SpacetimeDB will prompt you to confirm the deletion. Enter **y** and press **Enter** to proceed. +When using `--delete-data=always`, SpacetimeDB will prompt you to confirm the deletion. Enter **y** and press **Enter** to proceed. ::: ### Creating the Arena diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md index 4cb494183c2..a6a26a08526 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md @@ -520,7 +520,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Regenerate your server bindings with: @@ -917,7 +917,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). - Update the URL in the Unreal project to: `https://maincloud.spacetimedb.com` - Update the module name in the Unreal project to ``. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md index 845219c5e26..e061919b0c6 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md @@ -586,7 +586,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -606,7 +606,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -625,7 +625,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md index 0a4586a5216..2425f9b8d83 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -898,7 +898,7 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md index 71eff102a9c..e8b55a1bdc7 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md @@ -522,7 +522,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data +spacetime publish --server local blackholio --delete-data=always ``` Regenerate your server bindings with: @@ -844,7 +844,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). You will have to update the database name in `blackholio-server/spacetime.local.json` to match. - Update the URL in the Main node to: `https://maincloud.spacetimedb.com` - Update the database name in the Main node to ``. diff --git a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md index f8aaf847553..5e2f40b025c 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md +++ b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md @@ -95,7 +95,7 @@ If this publish is a major upgrade from 1.x to 2.0, read [1.x to 2.0 Upgrade Not To completely reset your database and delete all data: ```bash -spacetime publish --delete-data +spacetime publish --delete-data=always ``` ⚠️ **Warning:** This permanently deletes all data in your database! diff --git a/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md b/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md index 4a29ff7465f..59306940097 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md +++ b/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md @@ -59,13 +59,13 @@ The following changes cannot be performed with automatic migration and will caus If you need to make changes that aren't supported by automatic migration, see [Incremental Migrations](./00300-incremental-migrations.md) for a production-ready pattern that allows complex schema changes without downtime or data loss. -For development and testing, you can use `spacetime publish --delete-data` to completely reset your database, but this should **not** be used in production as it permanently deletes all data. +For development and testing, you can use `spacetime publish --delete-data=always` to completely reset your database, but this should **not** be used in production as it permanently deletes all data. ## Best Practices ### During Development -- Use `--delete-data` freely during early development when data loss is acceptable +- Use `--delete-data=always` freely during early development when data loss is acceptable - Test migrations with sample data before applying to production databases - Consider creating separate databases for development, staging, and production diff --git a/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md b/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md index 53d2503338c..1a2dedfddef 100644 --- a/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md +++ b/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md @@ -41,7 +41,7 @@ To update an existing module, run the same command. SpacetimeDB hot-swaps the mo To clear all data and start fresh: ```bash -spacetime publish my-database --server maincloud --delete-data +spacetime publish my-database --server maincloud --delete-data=always ``` ## Connecting Clients to Maincloud diff --git a/docs/docs/00300-resources/00200-reference/00100-cli-reference/00300-spacetime-json.md b/docs/docs/00300-resources/00200-reference/00100-cli-reference/00300-spacetime-json.md index f14340c3337..0e90d315c80 100644 --- a/docs/docs/00300-resources/00200-reference/00100-cli-reference/00300-spacetime-json.md +++ b/docs/docs/00300-resources/00200-reference/00100-cli-reference/00300-spacetime-json.md @@ -211,7 +211,7 @@ These apply to all selected databases: - `--server`: target server - `--break-clients`: allow breaking changes -- `--delete-data`: clear database data +- `--delete-data=`: clear database data (`always`, `on-conflict`, or `never`) - `--yes` / `--force`: skip confirmation prompts ### Per-database overrides From c849ef6b7143d6e6a958632bcf22c578206972cc Mon Sep 17 00:00:00 2001 From: rain Date: Fri, 10 Jul 2026 10:42:03 -0400 Subject: [PATCH 02/20] docs: keep delete-data examples concise --- .../00100-intro/00100-getting-started/00500-faq.md | 8 ++++---- .../00300-unity-tutorial/00300-part-2.md | 6 +++--- .../00300-unity-tutorial/00400-part-3.md | 8 ++++---- .../00300-unity-tutorial/00500-part-4.md | 4 ++-- .../00400-unreal-tutorial/00300-part-2.md | 6 +++--- .../00400-unreal-tutorial/00400-part-3.md | 10 +++++----- .../00400-unreal-tutorial/00500-part-4.md | 4 ++-- .../00500-godot-tutorial/00300-part-2.md | 6 +++--- .../00500-godot-tutorial/00400-part-3.md | 8 ++++---- .../00500-godot-tutorial/00500-part-4.md | 4 ++-- .../00100-databases/00300-spacetime-publish.md | 6 +++++- .../00500-migrations/00200-automatic-migrations.md | 4 ++-- .../00100-how-to/00100-deploy/00100-maincloud.md | 2 +- skills/cli/SKILL.md | 4 ++++ 14 files changed, 44 insertions(+), 36 deletions(-) diff --git a/docs/docs/00100-intro/00100-getting-started/00500-faq.md b/docs/docs/00100-intro/00100-getting-started/00500-faq.md index b96cd4f2f1f..abbbc177437 100644 --- a/docs/docs/00100-intro/00100-getting-started/00500-faq.md +++ b/docs/docs/00100-intro/00100-getting-started/00500-faq.md @@ -221,7 +221,7 @@ conn.subscriptionBuilder().subscribe( ### How do I handle schema migrations? -When you publish an updated module, SpacetimeDB compares the new schema with the existing one and performs automatic migrations for compatible changes (adding tables, adding columns with defaults, etc.). For breaking changes, you may need to publish with `--delete-data=always` during development. See [Automatic Migrations](../../00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md) for details on what changes are supported. +When you publish an updated module, SpacetimeDB compares the new schema with the existing one and performs automatic migrations for compatible changes (adding tables, adding columns with defaults, etc.). For breaking changes, you may need to publish with `--delete-data` during development. See [Automatic Migrations](../../00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md) for details on what changes are supported. ### How do I add a column to an existing table? @@ -261,10 +261,10 @@ Yes. When you `spacetime publish` an update, SpacetimeDB hot-swaps the module co ### How do I clear my database? -Use the `-c always` (or `--delete-data=always`) option when publishing: +Use the `-c` (or `--delete-data`) flag when publishing: ```bash -spacetime publish my-app -c always +spacetime publish my-app -c ``` This deletes all data and re-runs the `init` reducer. @@ -291,7 +291,7 @@ If your module's `init` reducer panics (for example, due to a unique constraint ### How do I reset my database during development? -Use `spacetime publish my-app --delete-data=always` to clear all data and republish. Or use `spacetime dev`, which handles this automatically with the `--delete-data=on-conflict` flag. +Use `spacetime publish my-app --delete-data` to clear all data and republish. Or use `spacetime dev`, which handles this automatically with the `--delete-data=on-conflict` flag. ### I got a weird error when compiling my module! diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md index 6cf56341ba5..033bd7ed2ea 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md @@ -587,7 +587,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -607,7 +607,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -626,7 +626,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md index 570c5a50d0b..fc5b6ae572c 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -898,7 +898,7 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md index bb7fb24b245..bfc58fc0ded 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md @@ -522,7 +522,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Regenerate your server bindings with: @@ -861,7 +861,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). You will have to update the database name in `blackholio-server/spacetime.local.json` to match. - Update the URL in the Unity project to: `https://maincloud.spacetimedb.com` - Update the module name in the Unity project to ``. diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md index 3d43ad8c38b..a592e63bfda 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md @@ -580,7 +580,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -600,7 +600,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -619,7 +619,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md index 74d7bba4ced..1b388814d96 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -894,13 +894,13 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. :::note -When using `--delete-data=always`, SpacetimeDB will prompt you to confirm the deletion. Enter **y** and press **Enter** to proceed. +When using `--delete-data`, SpacetimeDB will prompt you to confirm the deletion. Enter **y** and press **Enter** to proceed. ::: ### Creating the Arena diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md index a6a26a08526..4cb494183c2 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md @@ -520,7 +520,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Regenerate your server bindings with: @@ -917,7 +917,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). - Update the URL in the Unreal project to: `https://maincloud.spacetimedb.com` - Update the module name in the Unreal project to ``. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md index e061919b0c6..845219c5e26 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md @@ -586,7 +586,7 @@ The `ReducerKind.ClientConnected` argument to the `SpacetimeDB.Reducer` attribut > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `ReducerKind.Init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `ReducerKind.ClientConnected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `Sender` value of the `ReducerContext`. > - `ReducerKind.ClientDisconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -606,7 +606,7 @@ The `client_connected` argument to the `spacetimedb::reducer` macro indicates to > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `init` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `client_connected` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `client_disconnected` - Called when a user disconnects from the SpacetimeDB database. @@ -625,7 +625,7 @@ The `SPACETIMEDB_CLIENT_CONNECTED` macro indicates to SpacetimeDB that this is a > SpacetimeDB gives you the ability to define custom reducers that automatically trigger when certain events occur. > -> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data=always`. +> - `SPACETIMEDB_INIT` - Called the first time you publish your module and anytime you clear the database with `spacetime publish --server local --delete-data`. > - `SPACETIMEDB_CLIENT_CONNECTED` - Called when a user connects to the SpacetimeDB database. Their identity can be found in the `sender` value of the `ReducerContext`. > - `SPACETIMEDB_CLIENT_DISCONNECTED` - Called when a user disconnects from the SpacetimeDB database. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md index 2425f9b8d83..0a4586a5216 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md @@ -16,7 +16,7 @@ This progressive tutorial is continued from [part 2](./00300-part-2.md). -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `Init` reducer. SpacetimeDB calls the `Init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `Connect` reducer. @@ -85,7 +85,7 @@ We also added two helper functions so we can get a random range as either a `int -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `init` reducer. SpacetimeDB calls the `init` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -161,7 +161,7 @@ In this reducer, we are using the `world_size` we configured along with the `Red -Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data=always`. It gives you an opportunity to initialize the state of your database before any clients connect. +Let's start by spawning food into the map. The first thing we need to do is create a new, special reducer called the `SPACETIMEDB_INIT` reducer. SpacetimeDB calls the `SPACETIMEDB_INIT` reducer automatically when you first publish your module, and also after any time you run with `publish --delete-data`. It gives you an opportunity to initialize the state of your database before any clients connect. Add this new reducer above our `connect` reducer. @@ -898,7 +898,7 @@ SPACETIMEDB_CLIENT_DISCONNECTED(disconnect, ReducerContext ctx) { Finally, publish the new module to SpacetimeDB with this command: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Deleting the data is optional in this case, but in case you've been messing around with the module we can just start fresh. diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md index e8b55a1bdc7..71eff102a9c 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00500-part-4.md @@ -522,7 +522,7 @@ ctx.db[move_all_players_timer].insert(MoveAllPlayersTimer{ Republish your module with: ```sh -spacetime publish --server local blackholio --delete-data=always +spacetime publish --server local blackholio --delete-data ``` Regenerate your server bindings with: @@ -844,7 +844,7 @@ Notice that the food automatically respawns as you vaccuum them up. This is beca ## Connecting to Maincloud -- Publish to Maincloud `spacetime publish --server maincloud --delete-data=always` +- Publish to Maincloud `spacetime publish --server maincloud --delete-data` - `` This name should be unique and cannot contain any special characters other than internal hyphens (`-`). You will have to update the database name in `blackholio-server/spacetime.local.json` to match. - Update the URL in the Main node to: `https://maincloud.spacetimedb.com` - Update the database name in the Main node to ``. diff --git a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md index 5e2f40b025c..dd0402479a4 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md +++ b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md @@ -94,8 +94,12 @@ If this publish is a major upgrade from 1.x to 2.0, read [1.x to 2.0 Upgrade Not To completely reset your database and delete all data: + + ```bash -spacetime publish --delete-data=always +spacetime publish --delete-data ``` ⚠️ **Warning:** This permanently deletes all data in your database! diff --git a/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md b/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md index 59306940097..4a29ff7465f 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md +++ b/docs/docs/00200-core-concepts/00100-databases/00500-migrations/00200-automatic-migrations.md @@ -59,13 +59,13 @@ The following changes cannot be performed with automatic migration and will caus If you need to make changes that aren't supported by automatic migration, see [Incremental Migrations](./00300-incremental-migrations.md) for a production-ready pattern that allows complex schema changes without downtime or data loss. -For development and testing, you can use `spacetime publish --delete-data=always` to completely reset your database, but this should **not** be used in production as it permanently deletes all data. +For development and testing, you can use `spacetime publish --delete-data` to completely reset your database, but this should **not** be used in production as it permanently deletes all data. ## Best Practices ### During Development -- Use `--delete-data=always` freely during early development when data loss is acceptable +- Use `--delete-data` freely during early development when data loss is acceptable - Test migrations with sample data before applying to production databases - Consider creating separate databases for development, staging, and production diff --git a/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md b/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md index 1a2dedfddef..53d2503338c 100644 --- a/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md +++ b/docs/docs/00300-resources/00100-how-to/00100-deploy/00100-maincloud.md @@ -41,7 +41,7 @@ To update an existing module, run the same command. SpacetimeDB hot-swaps the mo To clear all data and start fresh: ```bash -spacetime publish my-database --server maincloud --delete-data=always +spacetime publish my-database --server maincloud --delete-data ``` ## Connecting Clients to Maincloud diff --git a/skills/cli/SKILL.md b/skills/cli/SKILL.md index 534ad7ee4ec..f5cd3479128 100644 --- a/skills/cli/SKILL.md +++ b/skills/cli/SKILL.md @@ -63,6 +63,10 @@ spacetime publish my-database --server local --yes spacetime publish my-database --delete-data=always --yes ``` +Bare `--delete-data` defaults to `always`. Keep simple interactive docs examples +bare, and use `--delete-data=always` for scripted/non-interactive examples that +also pass `--yes`. + ### Database Interaction ```bash From 4794bd4472b330fcfb92c5d229e567e5a8ef9bd9 Mon Sep 17 00:00:00 2001 From: rain Date: Sat, 11 Jul 2026 08:10:16 -0400 Subject: [PATCH 03/20] docs: clarify C# reducer result callbacks --- .../00600-clients/00600-csharp-reference.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md b/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md index 0db7e730c91..264ce97c797 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md +++ b/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md @@ -306,14 +306,14 @@ interface IRemoteDbContext ``` `Reducers` will have methods to invoke each reducer defined by the module, -plus methods for adding and removing callbacks on each of those reducers. +plus events for observing the result of reducer calls made by this connection. ##### Example ```csharp var conn = ConnectToDB(); -// Register a callback to be run every time the SendMessage reducer is invoked +// Register a callback to observe the result of SendMessage calls made by this connection. conn.Reducers.OnSendMessage += Reducer_OnSendMessageEvent; ``` @@ -711,9 +711,9 @@ record Event } ``` -Event when we are notified that a reducer ran in the remote database. The [`ReducerEvent`](#record-reducerevent) contains metadata about the reducer run, including its arguments and termination [`Status`](#record-status). +Event when we are notified of the result of a reducer call made by this connection. The [`ReducerEvent`](#record-reducerevent) contains metadata about the reducer run, including its arguments and termination [`Status`](#record-status). -This event is passed to row callbacks resulting from modifications by the reducer. +For changes caused by other clients' reducer calls, use table row callbacks or event tables rather than reducer callbacks. The server does not broadcast reducer arguments globally. #### Variant `SubscribeApplied` @@ -1084,13 +1084,14 @@ int CountPlayersAtLevel(RemoteTables tables, uint level) => tables.Player.Level. ## Observe and invoke reducers -All [`IDbContext`](#interface-idbcontext) implementors, including [`DbConnection`](#type-dbconnection) and [`EventContext`](#type-eventcontext), have a `.Reducers` property, which in turn has methods for invoking reducers defined by the module and registering callbacks on it. +All [`IDbContext`](#interface-idbcontext) implementors, including [`DbConnection`](#type-dbconnection) and [`EventContext`](#type-eventcontext), have a `.Reducers` property. Generated module bindings expose one invoke method and one result event for each reducer. -Each reducer defined by the module has three methods on the `.Reducers`: +For a reducer named `send_message`, generated C# bindings use PascalCase names: -- An invoke method, whose name is the reducer's name converted to snake case, like `set_name`. This requests that the module run the reducer. -- A callback registation method, whose name is prefixed with `on_`, like `on_set_name`. This registers a callback to run whenever we are notified that the reducer ran, including successfully committed runs and runs we requested which failed. This method returns a callback id, which can be passed to the callback remove method. -- A callback remove method, whose name is prefixed with `remove_on_`, like `remove_on_set_name`. This cancels a callback previously registered via the callback registration method. +- An invoke method, like `SendMessage(...)`. This requests that the module run the reducer. +- A result event, like `OnSendMessage`. This event fires on the calling connection when SpacetimeDB reports that reducer call's result, including committed, failed, and out-of-energy statuses. + +Reducer result events are not global notifications. They are for reducer calls made by this connection. To notify other clients that something happened, write to a public table or event table and subscribe to it. ## Identify a client From 7a9dc228504a884518810ae8a9aaaf69a6074a6e Mon Sep 17 00:00:00 2001 From: rain Date: Sun, 12 Jul 2026 08:10:29 -0400 Subject: [PATCH 04/20] docs: align TypeScript skill table naming guidance --- skills/typescript-server/SKILL.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/skills/typescript-server/SKILL.md b/skills/typescript-server/SKILL.md index e71e17a1290..83c51365d3b 100644 --- a/skills/typescript-server/SKILL.md +++ b/skills/typescript-server/SKILL.md @@ -23,7 +23,8 @@ import { ScheduleAt } from 'spacetimedb'; // for scheduled tables only ## Tables -`table(OPTIONS, COLUMNS)` takes two arguments. The `name` field MUST be snake_case: +`table(OPTIONS, COLUMNS)` takes two arguments. The `name` field is optional; +when present, it overrides the canonical SQL name and should be snake_case: ```typescript const entity = table( @@ -36,9 +37,11 @@ const entity = table( ); ``` -Options: `name` (snake_case, recommended), `public: true`, `event: true`, `scheduled: (): any => reducerRef`, `indexes: [...]` +Options: `name` (optional canonical SQL name override), `public: true`, `event: true`, `scheduled: (): any => reducerRef`, `indexes: [...]` -`ctx.db` accessors are the camelCase form of the table's `name` field. +`ctx.db` accessors come from the key passed to `schema({ ... })`, not from the +`name` override. If `name` is omitted, the canonical SQL name is derived from the +schema key. ## Column Types From 47b823cb8005a54ab82039043b6a26023241ea41 Mon Sep 17 00:00:00 2001 From: rain Date: Wed, 15 Jul 2026 08:10:37 -0400 Subject: [PATCH 05/20] docs: align TypeScript table accessor examples --- .../00200-functions/00300-reducers/00300-reducers.md | 8 ++++---- .../00300-reducers/00400-reducer-context.md | 6 +++--- .../00300-tables/00210-file-storage.md | 8 ++++---- .../00300-tables/00550-event-tables.md | 7 ++++--- .../00100-how-to/00600-migrating-to-2.0.md | 8 ++++---- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md index 4180d28ba6d..6238cf8eab4 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md @@ -546,7 +546,7 @@ import { ScheduleAt } from 'spacetimedb'; import { schema, t, table } from 'spacetimedb/server'; // Define a schedule table for the procedure -const fetchSchedule = table( +const fetch_schedule = table( { name: 'fetch_schedule', scheduled: (): any => fetch_external_data }, { scheduled_id: t.u64().primaryKey().autoInc(), @@ -555,12 +555,12 @@ const fetchSchedule = table( } ); -const spacetimedb = schema({ fetchSchedule }); +const spacetimedb = schema({ fetch_schedule }); export default spacetimedb; // The procedure to be scheduled export const fetch_external_data = spacetimedb.procedure( - { arg: fetchSchedule.rowType }, + { arg: fetch_schedule.rowType }, t.unit(), (ctx, { arg }) => { const response = ctx.http.fetch(arg.url); @@ -571,7 +571,7 @@ export const fetch_external_data = spacetimedb.procedure( // From a reducer, schedule the procedure by inserting into the schedule table export const queueFetch = spacetimedb.reducer({ url: t.string() }, (ctx, { url }) => { - ctx.db.fetchSchedule.insert({ + ctx.db.fetch_schedule.insert({ scheduled_id: 0n, scheduled_at: ScheduleAt.interval(0n), // Run immediately url, diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md index 06e30fb7b2a..e45f9174561 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md @@ -324,7 +324,7 @@ Scheduled reducers and procedures are private by default in SpacetimeDB 2.x, so ```typescript import { schema, table, t } from 'spacetimedb/server'; -const scheduledTask = table( +const scheduled_task = table( { name: 'scheduled_task', scheduled: (): any => send_reminder }, { taskId: t.u64().primaryKey().autoInc(), @@ -333,10 +333,10 @@ const scheduledTask = table( } ); -const spacetimedb = schema({ scheduledTask }); +const spacetimedb = schema({ scheduled_task }); export default spacetimedb; -export const send_reminder = spacetimedb.reducer({ arg: scheduledTask.rowType }, (_ctx, { arg }) => { +export const send_reminder = spacetimedb.reducer({ arg: scheduled_task.rowType }, (_ctx, { arg }) => { console.log(`Reminder: ${arg.message}`); }); ``` diff --git a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md index 86c1589ea46..9b88b2de7d8 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md +++ b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md @@ -20,7 +20,7 @@ Store binary data using `Vec` (Rust), `List` (C#), `std::vector { // Delete existing avatar if present - ctx.db.userAvatar.userId.delete(userId); + ctx.db.user_avatar.userId.delete(userId); // Insert new avatar - ctx.db.userAvatar.insert({ + ctx.db.user_avatar.insert({ userId, mimeType, data, diff --git a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md index 3f2936ca7ea..9bcdc1e5b52 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md +++ b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md @@ -21,7 +21,8 @@ To declare a table as an event table, add the `event` attribute to the table def ```typescript -const damageEvent = table({ +const damage_event = table({ + name: 'damage_event', public: true, event: true, }, { @@ -31,7 +32,7 @@ const damageEvent = table({ }); const spacetimedb = schema({ - damageEvent, + damage_event, }); export default spacetimedb; ``` @@ -97,7 +98,7 @@ export const attack = spacetimedb.reducer( // Game logic... // Publish the event - ctx.db.damageEvent.insert({ + ctx.db.damage_event.insert({ entity_id: target_id, damage, source: "melee_attack", diff --git a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md index 8f70388d274..aef29ff65f9 100644 --- a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md +++ b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md @@ -190,15 +190,15 @@ spacetimedb.reducer('deal_damage', { target: t.identity(), amount: t.u32() }, (c **Server (module) -- after:** ```typescript // 2.0 server -- explicitly publish events via an event table -const damageEvent = table({ event: true }, { +const damage_event = table({ name: 'damage_event', event: true }, { target: t.identity(), amount: t.u32(), }) -// schema() takes an object: schema({ damageEvent }), never schema(damageEvent) -const spacetimedb = schema({ damageEvent }); +// schema() takes an object: schema({ damage_event }), never schema(damage_event) +const spacetimedb = schema({ damage_event }); export const dealDamage = spacetimedb.reducer({ target: t.identity(), amount: t.u32() }, (ctx, { target, amount }) => { - ctx.db.damageEvent.insert({ target, amount }); + ctx.db.damage_event.insert({ target, amount }); }); ``` From 9dc58c7c2ff06fd85b84c14fe155f43a26938b9e Mon Sep 17 00:00:00 2001 From: rain Date: Fri, 17 Jul 2026 08:10:43 -0400 Subject: [PATCH 06/20] docs: align scheduled function examples --- .../00300-reducers/00400-reducer-context.md | 12 +++++----- .../00100-how-to/00600-migrating-to-2.0.md | 22 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md index e45f9174561..0db4503a469 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md @@ -327,8 +327,8 @@ import { schema, table, t } from 'spacetimedb/server'; const scheduled_task = table( { name: 'scheduled_task', scheduled: (): any => send_reminder }, { - taskId: t.u64().primaryKey().autoInc(), - scheduledAt: t.scheduleAt(), + task_id: t.u64().primaryKey().autoInc(), + scheduled_at: t.scheduleAt(), message: t.string(), } ); @@ -349,14 +349,14 @@ using SpacetimeDB; public static partial class Module { - [SpacetimeDB.Table(Accessor = "ScheduledTask", Scheduled = nameof(SendReminder))] + [SpacetimeDB.Table(Accessor = "ScheduledTask", Scheduled = nameof(SendReminder), ScheduledAt = nameof(ScheduledAt))] public partial struct ScheduledTask { [SpacetimeDB.PrimaryKey] [SpacetimeDB.AutoInc] - public ulong taskId; - public ScheduleAt scheduledAt; - public string message; + public ulong TaskId; + public ScheduleAt ScheduledAt; + public string Message; } [SpacetimeDB.Reducer] diff --git a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md index aef29ff65f9..bb91562f2b4 100644 --- a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md +++ b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md @@ -1366,14 +1366,14 @@ spacetimedb.reducer('runMyTimer', myTimer.rowType, (ctx, timer) => { ``` ```typescript -const myTimer = table({ scheduled: () => runMyTimer }, { - scheduledId: t.u64().primaryKey().autoInc(), - scheduledAt: t.scheduleAt(), +const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimer }, { + scheduled_id: t.u64().primaryKey().autoInc(), + scheduled_at: t.scheduleAt(), }); -const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) // 2.0 -- Can only be called by the database -export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Do stuff }) ``` @@ -1479,17 +1479,17 @@ In the rare event that you have a reducer or procedure which is intended to be i ```typescript -const myTimer = table({ scheduled: () => runMyTimerPrivate }, { - scheduledId: t.u64().primaryKey().autoInc(), - scheduledAt: t.scheduleAt(), +const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimerPrivate }, { + scheduled_id: t.u64().primaryKey().autoInc(), + scheduled_at: t.scheduleAt(), }); -const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) -export const runMyTimerPrivate = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimerPrivate = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Do stuff... }); -export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Same logic as runMyTimerPrivate — extract to a helper if needed }); ``` From 2caabd69fa1f9fa6acb1e44ee970d2da04dace9d Mon Sep 17 00:00:00 2001 From: rain Date: Sat, 18 Jul 2026 08:10:15 -0400 Subject: [PATCH 07/20] docs: update procedure language support overview --- .../00400-key-architecture.md | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md b/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md index 487b962f4ad..702e893bfea 100644 --- a/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md +++ b/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md @@ -345,9 +345,21 @@ ctx.procedures.makeRequest().then( -C# modules currently cannot define procedures. Support for defining procedures in C# modules will be released shortly. +C# modules can define procedures, but procedure support is currently unstable. +To use it, add `#pragma warning disable STDB_UNSTABLE` at the top of your file. -A C# [client](#client) can call a procedure defined by a Rust or TypeScript module: +```csharp +#pragma warning disable STDB_UNSTABLE + +[SpacetimeDB.Procedure] +public static string MakeRequest(ProcedureContext ctx) +{ + // ... + return "result"; +} +``` + +A C# [client](#client) can call a procedure defined by a module: ```csharp void Main() @@ -384,7 +396,7 @@ Because procedures are unstable, Rust modules that define them must opt in to th ```toml [dependencies] -spacetimedb = { version = "1.x", features = ["unstable"] } +spacetimedb = { version = "2.*", features = ["unstable"] } ``` Then, that module can define a procedure: @@ -436,7 +448,7 @@ Use the other tabs (TypeScript/C#/Rust/Unreal C++/Blueprint) for client call exa -An Unreal C++ [client](#client) can call a procedure defined by a Rust or TypeScript module: +An Unreal C++ [client](#client) can call a procedure defined by a module: ```cpp { @@ -468,7 +480,7 @@ void AGameManager::OnMakeRequestComplete(const FProcedureEventContext& Context, -An Unreal [client](#client) can call a procedure defined by a Rust or TypeScript module: +An Unreal [client](#client) can call a procedure defined by a module: ![MakeRequest without callback](/images/unreal/intro/ue-blueprint-makerequest-nocallback.png) From a129e9cd5813068fc99442be801fc864a26bfc69 Mon Sep 17 00:00:00 2001 From: rain Date: Sun, 19 Jul 2026 08:09:37 -0400 Subject: [PATCH 08/20] docs: clarify Unreal uproject-dir path --- .../00300-tutorials/00400-unreal-tutorial/00300-part-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md index a592e63bfda..c3113c50bf4 100644 --- a/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md +++ b/docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md @@ -655,7 +655,7 @@ spacetime generate --lang unrealcpp --uproject-dir .. --unreal-module-name black This will generate a set of files in the `blackholio/Source/blackholio/Private/ModuleBindings` and `blackholio/Source/blackholio/Public/ModuleBindings` directories which contain the code generated types and reducer functions that are defined in your module, but usable on the client. :::note -`--uproject-dir` is straightforward as the path to the .uproject file. `--unreal-module-name` is the name of the Unreal module which in most projects is the name of the project, in this case `blackholio`. +`--uproject-dir` is the path to the Unreal project directory that contains the `.uproject` file. `--unreal-module-name` is the name of the Unreal module, which in most projects is the name of the project, in this case `blackholio`. ::: :::warning From fab18a53cdb8bc089765c4b6f1e857a2598884e3 Mon Sep 17 00:00:00 2001 From: rain Date: Mon, 20 Jul 2026 08:10:51 -0400 Subject: [PATCH 09/20] docs: update Rust and C++ sender examples --- .../00300-tutorials/00300-unity-tutorial/00400-part-3.md | 6 +++--- .../00300-tutorials/00500-godot-tutorial/00400-part-3.md | 6 +++--- .../docs/00200-core-concepts/00200-functions/00500-views.md | 3 +-- .../00200-core-concepts/00300-tables/00210-file-storage.md | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md index fc5b6ae572c..01a99bcfc91 100644 --- a/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md @@ -721,7 +721,7 @@ const START_PLAYER_MASS: i32 = 15; #[spacetimedb::reducer] pub fn enter_game(ctx: &ReducerContext, name: String) -> Result<(), String> { log::info!("Creating player with name {}", name); - let mut player: Player = ctx.db.player().identity().find(ctx.sender).ok_or("")?; + let mut player: Player = ctx.db.player().identity().find(ctx.sender()).ok_or("")?; let player_id = player.player_id; player.name = name; ctx.db.player().identity().update(player); @@ -786,11 +786,11 @@ pub fn disconnect(ctx: &ReducerContext) -> Result<(), String> { .db .player() .identity() - .find(&ctx.sender) + .find(&ctx.sender()) .ok_or("Player not found")?; let player_id = player.player_id; ctx.db.logged_out_player().insert(player); - ctx.db.player().identity().delete(&ctx.sender); + ctx.db.player().identity().delete(&ctx.sender()); // Remove any circles from the arena for circle in ctx.db.circle().player_id().filter(&player_id) { diff --git a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md index 0a4586a5216..b5e3e4451fa 100644 --- a/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md +++ b/docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md @@ -721,7 +721,7 @@ const START_PLAYER_MASS: i32 = 15; #[spacetimedb::reducer] pub fn enter_game(ctx: &ReducerContext, name: String) -> Result<(), String> { log::info!("Creating player with name {}", name); - let mut player: Player = ctx.db.player().identity().find(ctx.sender).ok_or("")?; + let mut player: Player = ctx.db.player().identity().find(ctx.sender()).ok_or("")?; let player_id = player.player_id; player.name = name; ctx.db.player().identity().update(player); @@ -786,11 +786,11 @@ pub fn disconnect(ctx: &ReducerContext) -> Result<(), String> { .db .player() .identity() - .find(&ctx.sender) + .find(&ctx.sender()) .ok_or("Player not found")?; let player_id = player.player_id; ctx.db.logged_out_player().insert(player); - ctx.db.player().identity().delete(&ctx.sender); + ctx.db.player().identity().delete(&ctx.sender()); // Remove any circles from the arena for circle in ctx.db.circle().player_id().filter(&player_id) { diff --git a/docs/docs/00200-core-concepts/00200-functions/00500-views.md b/docs/docs/00200-core-concepts/00200-functions/00500-views.md index 89c2e1c2931..c6c1ade084f 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00500-views.md +++ b/docs/docs/00200-core-concepts/00200-functions/00500-views.md @@ -167,8 +167,7 @@ Views must be static methods and can return either a single row (`T?`) or multip Use the `#[spacetimedb::view]` macro on a function: ```rust -use spacetimedb::{view, ViewContext, AnonymousViewContext, table, SpacetimeType}; -use spacetimedb_lib::Identity; +use spacetimedb::{view, ViewContext, AnonymousViewContext, table, SpacetimeType, Identity}; #[spacetimedb::table(accessor = player)] pub struct Player { diff --git a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md index 9b88b2de7d8..bdab79ed169 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md +++ b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md @@ -332,7 +332,7 @@ SPACETIMEDB_REDUCER(register_document, ReducerContext ctx, std::string filename, std::string mime_type, uint64_t size_bytes, std::string storage_url) { ctx.db[document].insert(Document{ .id = 0, // auto-increment - .owner_id = ctx.sender, + .owner_id = ctx.sender(), .filename = filename, .mime_type = mime_type, .size_bytes = size_bytes, @@ -579,7 +579,7 @@ pub fn upload_to_s3( ctx.with_tx(|tx_ctx| { tx_ctx.db.document().insert(Document { id: 0, - owner_id: tx_ctx.sender, + owner_id: tx_ctx.sender(), filename: filename_clone.clone(), s3_key: s3_key_clone.clone(), uploaded_at: tx_ctx.timestamp, @@ -719,7 +719,7 @@ pub fn get_upload_url( pub fn confirm_upload(ctx: &ReducerContext, filename: String, s3_key: String) { ctx.db.document().insert(Document { id: 0, - owner_id: ctx.sender, + owner_id: ctx.sender(), filename, s3_key, uploaded_at: ctx.timestamp, From 03cc8c5a1782ce594b157b0776acd24596bae1c7 Mon Sep 17 00:00:00 2001 From: rain Date: Tue, 21 Jul 2026 08:10:14 -0400 Subject: [PATCH 10/20] Fix Rust codegen bindings path in docs --- docs/docs/00200-core-concepts/00600-clients/00200-codegen.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/00200-core-concepts/00600-clients/00200-codegen.md b/docs/docs/00200-core-concepts/00600-clients/00200-codegen.md index f380a574a68..acc6e7ef221 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00200-codegen.md +++ b/docs/docs/00200-core-concepts/00600-clients/00200-codegen.md @@ -57,10 +57,10 @@ Replace **PATH-TO-MODULE-DIRECTORY** with the path to your module's directory, w ```bash mkdir -p src/module_bindings -spacetime generate --lang rust --out-dir client/src/module_bindings --module-path PATH-TO-MODULE-DIRECTORY +spacetime generate --lang rust --out-dir src/module_bindings --module-path PATH-TO-MODULE-DIRECTORY ``` -This generates Rust files in `client/src/module_bindings/`. Import them in your client with: +This generates Rust files in `src/module_bindings/`. Import them in your client with: ```rust mod module_bindings; From f73fb9a7eba7f1a9fa75effc2822c46af7db5377 Mon Sep 17 00:00:00 2001 From: rain Date: Tue, 21 Jul 2026 14:21:42 -0400 Subject: [PATCH 11/20] docs: address audit PR review comments --- .../00400-key-architecture.md | 5 +--- .../00300-spacetime-publish.md | 4 --- .../00300-reducers/00300-reducers.md | 8 ++--- .../00300-reducers/00400-reducer-context.md | 10 +++---- .../00300-tables/00210-file-storage.md | 8 ++--- .../00100-how-to/00600-migrating-to-2.0.md | 30 +++++++++---------- 6 files changed, 29 insertions(+), 36 deletions(-) diff --git a/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md b/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md index 702e893bfea..10ba131faef 100644 --- a/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md +++ b/docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md @@ -345,12 +345,9 @@ ctx.procedures.makeRequest().then( -C# modules can define procedures, but procedure support is currently unstable. -To use it, add `#pragma warning disable STDB_UNSTABLE` at the top of your file. +C# modules can define procedures: ```csharp -#pragma warning disable STDB_UNSTABLE - [SpacetimeDB.Procedure] public static string MakeRequest(ProcedureContext ctx) { diff --git a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md index dd0402479a4..f8aaf847553 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md +++ b/docs/docs/00200-core-concepts/00100-databases/00300-spacetime-publish.md @@ -94,10 +94,6 @@ If this publish is a major upgrade from 1.x to 2.0, read [1.x to 2.0 Upgrade Not To completely reset your database and delete all data: - - ```bash spacetime publish --delete-data ``` diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md index 6238cf8eab4..4180d28ba6d 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md @@ -546,7 +546,7 @@ import { ScheduleAt } from 'spacetimedb'; import { schema, t, table } from 'spacetimedb/server'; // Define a schedule table for the procedure -const fetch_schedule = table( +const fetchSchedule = table( { name: 'fetch_schedule', scheduled: (): any => fetch_external_data }, { scheduled_id: t.u64().primaryKey().autoInc(), @@ -555,12 +555,12 @@ const fetch_schedule = table( } ); -const spacetimedb = schema({ fetch_schedule }); +const spacetimedb = schema({ fetchSchedule }); export default spacetimedb; // The procedure to be scheduled export const fetch_external_data = spacetimedb.procedure( - { arg: fetch_schedule.rowType }, + { arg: fetchSchedule.rowType }, t.unit(), (ctx, { arg }) => { const response = ctx.http.fetch(arg.url); @@ -571,7 +571,7 @@ export const fetch_external_data = spacetimedb.procedure( // From a reducer, schedule the procedure by inserting into the schedule table export const queueFetch = spacetimedb.reducer({ url: t.string() }, (ctx, { url }) => { - ctx.db.fetch_schedule.insert({ + ctx.db.fetchSchedule.insert({ scheduled_id: 0n, scheduled_at: ScheduleAt.interval(0n), // Run immediately url, diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md index 0db4503a469..4a3e68d358e 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md @@ -324,19 +324,19 @@ Scheduled reducers and procedures are private by default in SpacetimeDB 2.x, so ```typescript import { schema, table, t } from 'spacetimedb/server'; -const scheduled_task = table( +const scheduledTask = table( { name: 'scheduled_task', scheduled: (): any => send_reminder }, { - task_id: t.u64().primaryKey().autoInc(), - scheduled_at: t.scheduleAt(), + taskId: t.u64().primaryKey().autoInc(), + scheduledAt: t.scheduleAt(), message: t.string(), } ); -const spacetimedb = schema({ scheduled_task }); +const spacetimedb = schema({ scheduledTask }); export default spacetimedb; -export const send_reminder = spacetimedb.reducer({ arg: scheduled_task.rowType }, (_ctx, { arg }) => { +export const send_reminder = spacetimedb.reducer({ arg: scheduledTask.rowType }, (_ctx, { arg }) => { console.log(`Reminder: ${arg.message}`); }); ``` diff --git a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md index bdab79ed169..ba5f8b5f2fe 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md +++ b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md @@ -20,7 +20,7 @@ Store binary data using `Vec` (Rust), `List` (C#), `std::vector { // Delete existing avatar if present - ctx.db.user_avatar.userId.delete(userId); + ctx.db.userAvatar.userId.delete(userId); // Insert new avatar - ctx.db.user_avatar.insert({ + ctx.db.userAvatar.insert({ userId, mimeType, data, diff --git a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md index bb91562f2b4..e094d2f30c4 100644 --- a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md +++ b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md @@ -190,15 +190,15 @@ spacetimedb.reducer('deal_damage', { target: t.identity(), amount: t.u32() }, (c **Server (module) -- after:** ```typescript // 2.0 server -- explicitly publish events via an event table -const damage_event = table({ name: 'damage_event', event: true }, { +const damageEvent = table({ name: 'damage_event', event: true }, { target: t.identity(), amount: t.u32(), }) -// schema() takes an object: schema({ damage_event }), never schema(damage_event) -const spacetimedb = schema({ damage_event }); +// schema() takes an object: schema({ damageEvent }), never schema(damageEvent) +const spacetimedb = schema({ damageEvent }); export const dealDamage = spacetimedb.reducer({ target: t.identity(), amount: t.u32() }, (ctx, { target, amount }) => { - ctx.db.damage_event.insert({ target, amount }); + ctx.db.damageEvent.insert({ target, amount }); }); ``` @@ -1366,14 +1366,14 @@ spacetimedb.reducer('runMyTimer', myTimer.rowType, (ctx, timer) => { ``` ```typescript -const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimer }, { - scheduled_id: t.u64().primaryKey().autoInc(), - scheduled_at: t.scheduleAt(), +const myTimer = table({ name: 'my_timer', scheduled: (): any => runMyTimer }, { + scheduledId: t.u64().primaryKey().autoInc(), + scheduledAt: t.scheduleAt(), }); -const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) // 2.0 -- Can only be called by the database -export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { // Do stuff }) ``` @@ -1479,17 +1479,17 @@ In the rare event that you have a reducer or procedure which is intended to be i ```typescript -const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimerPrivate }, { - scheduled_id: t.u64().primaryKey().autoInc(), - scheduled_at: t.scheduleAt(), +const myTimer = table({ name: 'my_timer', scheduled: (): any => runMyTimerPrivate }, { + scheduledId: t.u64().primaryKey().autoInc(), + scheduledAt: t.scheduleAt(), }); -const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) -export const runMyTimerPrivate = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { +export const runMyTimerPrivate = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { // Do stuff... }); -export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { // Same logic as runMyTimerPrivate — extract to a helper if needed }); ``` From 077a8c6bac4f15c359ac0b7a8815ab20d94913f3 Mon Sep 17 00:00:00 2001 From: rain Date: Wed, 22 Jul 2026 08:10:19 -0400 Subject: [PATCH 12/20] docs: align reducer context docs with SDK --- .../00300-reducers/00400-reducer-context.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md index 4a3e68d358e..c79d779959b 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md @@ -131,7 +131,7 @@ Every reducer invocation has an associated caller identity. ```typescript -import { schema, table, t, type Identity } from 'spacetimedb/server'; +import { schema, table, t } from 'spacetimedb/server'; const player = table( { name: 'player', public: true }, @@ -257,7 +257,7 @@ SPACETIMEDB_REDUCER(update_score, ReducerContext ctx, uint32_t new_score) { The connection ID identifies the specific client connection that invoked the reducer. This is useful for tracking sessions or implementing per-connection state. :::note -The connection ID may be `None`/`null`/`undefined` for reducers invoked by the system (such as scheduled reducers or lifecycle reducers) or when called via the CLI without specifying a connection. +The connection ID may be absent for reducers invoked by the system (such as scheduled reducers or lifecycle reducers) or when called via the CLI without specifying a connection. In TypeScript modules, `ctx.connectionId` is `ConnectionId | null`. ::: ### Timestamp @@ -362,7 +362,7 @@ public static partial class Module [SpacetimeDB.Reducer] public static void SendReminder(ReducerContext _ctx, ScheduledTask task) { - Log.Info($"Reminder: {task.message}"); + Log.Info($"Reminder: {task.Message}"); } } ``` @@ -426,7 +426,7 @@ SPACETIMEDB_REDUCER(send_reminder, ReducerContext _ctx, ScheduledTask task) { | `db` | `DbView` | Access to the module's database tables | | `sender` | `Identity` | Identity of the caller | | `senderAuth` | `AuthCtx` | Authorization context for the caller (includes JWT claims and internal call detection) | -| `connectionId` | `ConnectionId \| undefined`| Connection ID of the caller, if available | +| `connectionId` | `ConnectionId \| null` | Connection ID of the caller, if available | | `timestamp` | `Timestamp` | Time when the reducer was invoked | | `random` | `Random` | Random number generator (deterministic, seeded by SpacetimeDB) | From e52c15ffe747a9a4a101e9f2fe0d598c81984252 Mon Sep 17 00:00:00 2001 From: rain Date: Thu, 23 Jul 2026 08:10:34 -0400 Subject: [PATCH 13/20] docs: update C# reducer failure pattern --- .../00300-resources/00100-how-to/00600-migrating-to-2.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md index e094d2f30c4..e70bad128de 100644 --- a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md +++ b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md @@ -107,9 +107,9 @@ conn.Reducers.OnDealDamage += (ctx, _, _) => { Console.WriteLine("Reducer succeeded"); } - else if (ctx.Event.Status is Status.Failed failed) + else if (ctx.Event.Status is Status.Failed(var reason)) { - Console.WriteLine($"Reducer failed: {failed}"); + Console.WriteLine($"Reducer failed: {reason}"); } else if (ctx.Event.Status is Status.OutOfEnergy) { From 879a02804664557bd79ab07c5159ea8d572f3ade Mon Sep 17 00:00:00 2001 From: rain Date: Sat, 25 Jul 2026 08:09:32 -0400 Subject: [PATCH 14/20] docs: fix HTTP handler route placeholder --- .../00200-functions/00600-HTTP-handlers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/00200-core-concepts/00200-functions/00600-HTTP-handlers.md b/docs/docs/00200-core-concepts/00200-functions/00600-HTTP-handlers.md index c8bc481d338..9696462542d 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00600-HTTP-handlers.md +++ b/docs/docs/00200-core-concepts/00200-functions/00600-HTTP-handlers.md @@ -7,7 +7,7 @@ import Tabs from '@theme/Tabs' import TabItem from '@theme/TabItem' HTTP handlers allow a SpacetimeDB database to expose an HTTP API. -External clients can make HTTP requests to routes nested under [`/v1/database/:name_or_address/route`](../../00300-resources/00200-reference/00200-http-api/00300-database.md#any-v1databasename_or_identityroutepath); these requests are resolved to routes defined by the database and then passed to the corresponding HTTP handler. +External clients can make HTTP requests to routes nested under [`/v1/database/:name_or_identity/route`](../../00300-resources/00200-reference/00200-http-api/00300-database.md#any-v1databasename_or_identityroutepath); these requests are resolved to routes defined by the database and then passed to the corresponding HTTP handler. :::warning ***HTTP handlers are currently in beta, and their API may change in upcoming SpacetimeDB releases.*** @@ -225,4 +225,4 @@ SpacetimeDB uses strict routing, meaning that a request must match a path exactl ## Sending Requests -Routes defined by a SpacetimeDB database are exposed under the prefix `/v1/database/:name/route`. To access the `say-hello` route above, send a request to `$SPACETIMEDB_URI/v1/database/$DATABASE/route/say-hello`, where `$SPACETIMEDB_URI` is the SpacetimeDB host (usually `https://maincloud.spacetimedb.com`), and `$DATABASE` is the name of the database. +Routes defined by a SpacetimeDB database are exposed under the prefix `/v1/database/:name_or_identity/route`. To access the `say-hello` route above, send a request to `$SPACETIMEDB_URI/v1/database/$DATABASE/route/say-hello`, where `$SPACETIMEDB_URI` is the SpacetimeDB host (usually `https://maincloud.spacetimedb.com`), and `$DATABASE` is the name or identity of the database. From e03a492df84a9252457c4c8fd2d22c9ffcf64655 Mon Sep 17 00:00:00 2001 From: rain Date: Sun, 26 Jul 2026 08:09:54 -0400 Subject: [PATCH 15/20] docs: avoid ambient clock in file storage examples --- .../00200-core-concepts/00300-tables/00210-file-storage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md index ba5f8b5f2fe..5a9192d1cc0 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md +++ b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md @@ -405,7 +405,7 @@ export const upload_to_s3 = spacetimedb.procedure( t.string(), // Returns the S3 key (ctx, { filename, contentType, data, s3Bucket, s3Region }) => { // Generate a unique S3 key - const s3Key = `uploads/${Date.now()}-${filename}`; + const s3Key = `uploads/${ctx.timestamp.microsSinceUnixEpoch}-${filename}`; const url = `https://${s3Bucket}.s3.${s3Region}.amazonaws.com/${s3Key}`; // Upload to S3 (simplified - add AWS4 signature in production) @@ -610,7 +610,7 @@ export const get_upload_url = spacetimedb.procedure( { filename: t.string(), contentType: t.string() }, t.object('UploadInfo', { uploadUrl: t.string(), s3Key: t.string() }), (ctx, { filename, contentType }) => { - const s3Key = `uploads/${Date.now()}-${filename}`; + const s3Key = `uploads/${ctx.timestamp.microsSinceUnixEpoch}-${filename}`; // Generate pre-signed URL (requires AWS credentials and signing logic) const uploadUrl = generatePresignedUrl(s3Key, contentType); From 4e4902824aed5e87d534b768106755427f6a1604 Mon Sep 17 00:00:00 2001 From: rain Date: Mon, 27 Jul 2026 08:10:17 -0400 Subject: [PATCH 16/20] docs: correct TypeScript connectionId nullability --- .../00200-core-concepts/00100-databases/00500-cheat-sheet.md | 2 +- .../00200-functions/00300-reducers/00500-lifecycle.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md b/docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md index 55b95444cff..5ecd5421564 100644 --- a/docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md +++ b/docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md @@ -775,7 +775,7 @@ SPACETIMEDB_VIEW(std::optional, player_count, Public, AnonymousView ```typescript ctx.db // Database access ctx.sender // Identity of caller -ctx.connectionId // ConnectionId | undefined +ctx.connectionId // ConnectionId | null ctx.timestamp // Timestamp ctx.databaseIdentity // Module's identity ``` diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00500-lifecycle.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00500-lifecycle.md index b679d90ef82..a7a13cc3e5d 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00500-lifecycle.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00500-lifecycle.md @@ -385,5 +385,5 @@ Reducers can be triggered at specific times using schedule tables. See [Schedule :::info Scheduled Reducer Context Scheduled reducer calls originate from SpacetimeDB itself, not from a client. Therefore: - `ctx.sender()` will be the module's own identity -- `ctx.connection_id()` will be `None`/`null`/`undefined` +- The connection ID will be absent (`null` in TypeScript, `null` in C#, `None` in Rust, and `std::nullopt` in C++) ::: From bb430701d7261aeee6867c4ff96ddb68dae9ef58 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Tue, 28 Jul 2026 08:10:19 -0400 Subject: [PATCH 17/20] docs: clarify TypeScript provider reconnect behavior --- .../00200-core-concepts/00600-clients/00300-connection.md | 6 +++--- .../00600-clients/00700-typescript-reference.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/00200-core-concepts/00600-clients/00300-connection.md b/docs/docs/00200-core-concepts/00600-clients/00300-connection.md index f1ad4c73d42..e5378e4eddc 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00300-connection.md +++ b/docs/docs/00200-core-concepts/00600-clients/00300-connection.md @@ -397,11 +397,11 @@ Conn->Disconnect(); ### Reconnection Behavior -:::note[Current Limitation] +:::note[Reconnection behavior] -Automatic reconnection behavior is inconsistently implemented across SDKs. If your connection is interrupted, you may need to create a new `DbConnection` to re-establish connectivity. +Lower-level `DbConnection` objects do not reconnect themselves. If you create a `DbConnection` directly and the connection is interrupted, create a new `DbConnection` to re-establish connectivity. -We recommend implementing reconnection logic in your application if reliable connectivity is critical. +The TypeScript React, Solid, and Svelte providers manage their connections through the SDK's shared connection manager. While a provider is mounted, that manager automatically rebuilds unexpectedly closed connections with exponential backoff and re-checks connection liveness when the page becomes visible, regains focus, returns online, or is restored from the back-forward cache. ::: diff --git a/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md b/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md index 6f1b6eeecad..ef9a5ab9798 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md +++ b/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md @@ -1034,7 +1034,7 @@ The SpacetimeDB TypeScript SDK includes React bindings under the `spacetimedb/re The React integration is fully compatible with React StrictMode and correctly handles the double-mount behavior (only one WebSocket connection is created). -While a `SpacetimeDBProvider` is mounted, the React connection manager also replaces the managed `DbConnection` if the underlying WebSocket closes or reports a connection error. Reconnect attempts use exponential backoff, starting at 1 second and doubling after each consecutive failure up to a 30 second maximum; the backoff resets after a successful connection. Hooks such as `useTable` observe the provider state, receive the fresh connection, and establish their subscriptions again; while the replacement connection is being established, `useTable` reports `isReady` as `false` until its subscription is applied on the new connection. This provider-level recovery does not change the lower-level `DbConnection` contract: applications that create a `DbConnection` directly are still responsible for creating a new connection if they need reconnection behavior. +While a `SpacetimeDBProvider` is mounted, the shared connection manager also replaces the managed `DbConnection` if the underlying WebSocket closes or reports a connection error. Reconnect attempts use exponential backoff, starting at 1 second and doubling after each consecutive failure up to a 30 second maximum; the backoff resets after a successful connection. In browser environments, the manager also re-checks connection liveness when the page becomes visible, regains focus, returns online, or is restored from the back-forward cache, so a stalled reconnect or silently closed socket can be rebuilt promptly after a suspended tab resumes. Hooks such as `useTable` observe the provider state, receive the fresh connection, and establish their subscriptions again; while the replacement connection is being established, `useTable` reports `isReady` as `false` until its subscription is applied on the new connection. This provider-level recovery does not change the lower-level `DbConnection` contract: applications that create a `DbConnection` directly are still responsible for creating a new connection if they need reconnection behavior. | Name | Description | | ----------------------------------------------------------- | --------------------------------------------------------- | From e6f1e64871943c347466274df70b1c595701724d Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Thu, 30 Jul 2026 08:10:17 -0400 Subject: [PATCH 18/20] docs: clarify event table subscribe-all behavior --- .../docs/00200-core-concepts/00300-tables/00550-event-tables.md | 2 +- .../00200-core-concepts/00600-clients/00600-csharp-reference.md | 2 +- .../00600-clients/00700-typescript-reference.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md index 9bcdc1e5b52..306fa92272c 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md +++ b/docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md @@ -175,7 +175,7 @@ This behavior follows naturally from the fact that event table rows are never me ## Subscribing to Events -On the client side, event tables are subscribed to in the same way as regular tables. The important difference is that event table rows are never stored in the client cache. Calling `count()` on an event table always returns 0, and `iter()` always yields no rows. Instead, you observe events through `on_insert` callbacks, which fire for each row that was inserted during the transaction. +On the client side, event tables are subscribed to with explicit queries, just like regular tables. Subscribe-all helpers such as `subscribeToAllTables`, `SubscribeToAllTables`, and `subscribe_to_all_tables` do not include event tables. Once subscribed, event table rows are never stored in the client cache. Calling `count()` on an event table always returns 0, and `iter()` always yields no rows. Instead, you observe events through `on_insert` callbacks, which fire for each row that was inserted during the transaction. Because event table rows are ephemeral, only `on_insert` callbacks are available. There are no `on_delete`, `on_update`, or `on_before_delete` callbacks, since rows are never present in the client state to be deleted or updated. diff --git a/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md b/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md index 264ce97c797..e5cd26b9363 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md +++ b/docs/docs/00200-core-concepts/00600-clients/00600-csharp-reference.md @@ -425,7 +425,7 @@ class SubscriptionBuilder } ``` -Subscribe to all rows from all public tables. This method is provided as a convenience for simple clients. The subscription initiated by `SubscribeToAllTables` cannot be canceled after it is initiated. You should [`subscribe` to specific queries](#method-subscribe) if you need fine-grained control over the lifecycle of your subscriptions. +Subscribe to all rows from all public non-event tables. Event tables are excluded and must be subscribed to with explicit queries. This method is provided as a convenience for simple clients. The subscription initiated by `SubscribeToAllTables` cannot be canceled after it is initiated. You should [`subscribe` to specific queries](#method-subscribe) if you need fine-grained control over the lifecycle of your subscriptions. #### Type `TypedSubscriptionBuilder` diff --git a/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md b/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md index ef9a5ab9798..657ff8397b3 100644 --- a/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md +++ b/docs/docs/00200-core-concepts/00600-clients/00700-typescript-reference.md @@ -384,7 +384,7 @@ class SubscriptionBuilder { } ``` -Subscribe to all rows from all public tables. This method is provided as a convenience for simple clients. The subscription initiated by `subscribeToAllTables` cannot be canceled after it is initiated. You should [`subscribe` to specific queries](#method-subscribe) if you need fine-grained control over the lifecycle of your subscriptions. +Subscribe to all rows from all public non-event tables. Event tables are excluded and must be subscribed to with explicit queries. This method is provided as a convenience for simple clients. The subscription initiated by `subscribeToAllTables` cannot be canceled after it is initiated. You should [`subscribe` to specific queries](#method-subscribe) if you need fine-grained control over the lifecycle of your subscriptions. ## Query Builder API From 3b711778717a09bc3c3a4eb501bc112188cc0c07 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Fri, 31 Jul 2026 08:10:31 -0400 Subject: [PATCH 19/20] docs: update C# reducer callback tutorial wording --- .../00100-intro/00300-tutorials/00100-chat-app.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md index 96ed9018dfd..954fb903712 100644 --- a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md +++ b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md @@ -2042,7 +2042,10 @@ void PrintMessage(RemoteTables tables, Message message) #### Warn if our name was rejected -We can also register callbacks to run each time a reducer is invoked. We register these callbacks using the `OnReducerEvent` method of the `Reducer` namespace, which is automatically implemented for each reducer by `spacetime generate`. +We can also register callbacks for reducer results. We register these callbacks +using generated events on `conn.Reducers`, such as `conn.Reducers.OnSetName` +and `conn.Reducers.OnSendMessage`, which are automatically implemented for +each reducer by `spacetime generate`. Each reducer callback takes one fixed argument: @@ -2061,7 +2064,11 @@ These callbacks will be invoked in one of two cases: Note that a status of `Failed` or `OutOfEnergy` implies that the caller identity is our own identity. -We already handle successful `SetName` invocations using our `User.OnUpdate` callback, but if the module rejects a user's chosen name, we'd like that user's client to let them know. We define a function `Reducer_OnSetNameEvent` as a `Reducer.OnSetNameEvent` callback which checks if the reducer failed, and if it did, prints an error message including the rejected name. +We already handle successful `SetName` invocations using our `User.OnUpdate` +callback, but if the module rejects a user's chosen name, we'd like that user's +client to let them know. We define a function `Reducer_OnSetNameEvent` and +register it with `conn.Reducers.OnSetName`; the callback checks if the reducer +failed, and if it did, prints an error message including the rejected name. We'll test both that our identity matches the sender and that the status is `Failed`, even though the latter implies the former, for demonstration purposes. From fc626dc3abe4b4f66726bca4d1f39ae9097b63c3 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Sat, 1 Aug 2026 08:12:04 -0400 Subject: [PATCH 20/20] docs: align TypeScript table accessor examples --- .../00300-reducers/00300-reducers.md | 8 ++--- .../00300-reducers/00400-reducer-context.md | 6 ++-- .../00200-functions/00400-procedures.md | 14 ++++----- .../00200-functions/00500-views.md | 24 +++++++-------- .../00300-tables/00210-file-storage.md | 8 ++--- .../00300-tables/00400-access-permissions.md | 6 ++-- .../00100-how-to/00600-migrating-to-2.0.md | 30 +++++++++---------- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md index 4180d28ba6d..6238cf8eab4 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00300-reducers.md @@ -546,7 +546,7 @@ import { ScheduleAt } from 'spacetimedb'; import { schema, t, table } from 'spacetimedb/server'; // Define a schedule table for the procedure -const fetchSchedule = table( +const fetch_schedule = table( { name: 'fetch_schedule', scheduled: (): any => fetch_external_data }, { scheduled_id: t.u64().primaryKey().autoInc(), @@ -555,12 +555,12 @@ const fetchSchedule = table( } ); -const spacetimedb = schema({ fetchSchedule }); +const spacetimedb = schema({ fetch_schedule }); export default spacetimedb; // The procedure to be scheduled export const fetch_external_data = spacetimedb.procedure( - { arg: fetchSchedule.rowType }, + { arg: fetch_schedule.rowType }, t.unit(), (ctx, { arg }) => { const response = ctx.http.fetch(arg.url); @@ -571,7 +571,7 @@ export const fetch_external_data = spacetimedb.procedure( // From a reducer, schedule the procedure by inserting into the schedule table export const queueFetch = spacetimedb.reducer({ url: t.string() }, (ctx, { url }) => { - ctx.db.fetchSchedule.insert({ + ctx.db.fetch_schedule.insert({ scheduled_id: 0n, scheduled_at: ScheduleAt.interval(0n), // Run immediately url, diff --git a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md index c79d779959b..8a0e40d64ae 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md +++ b/docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md @@ -324,7 +324,7 @@ Scheduled reducers and procedures are private by default in SpacetimeDB 2.x, so ```typescript import { schema, table, t } from 'spacetimedb/server'; -const scheduledTask = table( +const scheduled_task = table( { name: 'scheduled_task', scheduled: (): any => send_reminder }, { taskId: t.u64().primaryKey().autoInc(), @@ -333,10 +333,10 @@ const scheduledTask = table( } ); -const spacetimedb = schema({ scheduledTask }); +const spacetimedb = schema({ scheduled_task }); export default spacetimedb; -export const send_reminder = spacetimedb.reducer({ arg: scheduledTask.rowType }, (_ctx, { arg }) => { +export const send_reminder = spacetimedb.reducer({ arg: scheduled_task.rowType }, (_ctx, { arg }) => { console.log(`Reminder: ${arg.message}`); }); ``` diff --git a/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md b/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md index 32589a22a88..f96b8e238ec 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md +++ b/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md @@ -128,7 +128,7 @@ This means there's no `ctx.db` field to access the database. Instead, procedure code must manage transactions explicitly with `ProcedureCtx.withTx`. ```typescript -const myTable = table( +const my_table = table( { name: "my_table" }, { a: t.u32(), @@ -136,12 +136,12 @@ const myTable = table( }, ) -const spacetimedb = schema({ myTable }); +const spacetimedb = schema({ my_table }); export default spacetimedb; export const insert_a_value = spacetimedb.procedure({ a: t.u32(), b: t.u32() }, t.unit(), (ctx, { a, b }) => { ctx.withTx(ctx => { - ctx.db.myTable.insert({ a, b }); + ctx.db.my_table.insert({ a, b }); }); return {}; }) @@ -328,7 +328,7 @@ export const maybe_insert_a_value = spacetimedb.procedure({ a: t.u32(), b: t.str if (a < 10) { throw new SenderError("a is less than 10!"); } - ctx.db.myTable.insert({ a, b }); + ctx.db.my_table.insert({ a, b }); }); }) ``` @@ -1190,7 +1190,7 @@ A common use case for procedures is integrating with external APIs like OpenAI's import { schema, t, table, SenderError } from 'spacetimedb/server'; import { TimeDuration } from 'spacetimedb'; -const aiMessage = table( +const ai_message = table( { name: 'ai_message', public: true }, { user: t.identity(), @@ -1200,7 +1200,7 @@ const aiMessage = table( } ); -const spacetimedb = schema({ aiMessage }); +const spacetimedb = schema({ ai_message }); export default spacetimedb; export const ask_ai = spacetimedb.procedure( @@ -1235,7 +1235,7 @@ export const ask_ai = spacetimedb.procedure( // Store the conversation in the database ctx.withTx(txCtx => { - txCtx.db.aiMessage.insert({ + txCtx.db.ai_message.insert({ user: txCtx.sender, prompt, response: aiResponse, diff --git a/docs/docs/00200-core-concepts/00200-functions/00500-views.md b/docs/docs/00200-core-concepts/00200-functions/00500-views.md index c6c1ade084f..d86af13564c 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00500-views.md +++ b/docs/docs/00200-core-concepts/00200-functions/00500-views.md @@ -40,7 +40,7 @@ const players = table( } ); -const playerLevels = table( +const player_levels = table( { name: 'player_levels', public: true }, { player_id: t.u64().unique(), @@ -48,7 +48,7 @@ const playerLevels = table( } ); -const spacetimedb = schema({ players, playerLevels }); +const spacetimedb = schema({ players, player_levels }); export default spacetimedb; // At-most-one row: return Option via t.option(...) @@ -75,7 +75,7 @@ export const players_for_level = spacetimedb.anonymousView( t.array(playerAndLevelRow), (ctx) => { const out: Array<{ id: bigint; name: string; level: bigint }> = []; - for (const playerLevel of ctx.db.playerLevels.level.filter(2n)) { + for (const playerLevel of ctx.db.player_levels.level.filter(2n)) { const p = ctx.db.players.id.find(playerLevel.player_id); if (p) out.push({ id: p.id, name: p.name, level: playerLevel.level }); } @@ -493,7 +493,7 @@ const entity = table( ); // Track which chunks each player is subscribed to -const playerChunk = table( +const player_chunk = table( { name: 'player_chunk', public: true }, { playerId: t.u64().primaryKey(), @@ -521,7 +521,7 @@ export const entities_in_my_chunk = spacetimedb.view( const player = ctx.db.players.identity.find(ctx.sender); if (!player) return []; - const chunk = ctx.db.playerChunk.playerId.find(player.id); + const chunk = ctx.db.player_chunk.playerId.find(player.id); if (!chunk) return []; return Array.from(ctx.db.entity.chunkX.filter(chunk.chunkX)) @@ -1067,7 +1067,7 @@ const players = table( } ); -const playerLevels = table( +const player_levels = table( { name: 'player_levels', public: true }, { player_id: t.u64().unique(), @@ -1075,7 +1075,7 @@ const playerLevels = table( } ); -const spacetimedb = schema({ players, playerLevels }); +const spacetimedb = schema({ players, player_levels }); export default spacetimedb; export const all_players = spacetimedb.anonymousView( @@ -1086,8 +1086,8 @@ export const all_players = spacetimedb.anonymousView( export const all_player_levels = spacetimedb.anonymousView( { name: 'all_player_levels', public: true }, - t.array(playerLevels.rowType), - (ctx) => ctx.from.playerLevels + t.array(player_levels.rowType), + (ctx) => ctx.from.player_levels ); ``` @@ -1342,17 +1342,17 @@ export const players_with_levels = spacetimedb.anonymousView( t.array(players.rowType), (ctx) => { return ctx.from.players - .leftSemijoin(ctx.from.playerLevels, (p, pl) => p.id.eq(pl.player_id)); + .leftSemijoin(ctx.from.player_levels, (p, pl) => p.id.eq(pl.player_id)); } ); export const levels_for_high_scorers = spacetimedb.anonymousView( { name: 'levels_for_high_scorers', public: true }, - t.array(playerLevels.rowType), + t.array(player_levels.rowType), (ctx) => { return ctx.from.players .where(p => p.score.gte(1000n)) - .rightSemijoin(ctx.from.playerLevels, (p, pl) => p.id.eq(pl.player_id)) + .rightSemijoin(ctx.from.player_levels, (p, pl) => p.id.eq(pl.player_id)) .where(pl => pl.level.gte(10n)); } ); diff --git a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md index 5a9192d1cc0..68087bcdda9 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md +++ b/docs/docs/00200-core-concepts/00300-tables/00210-file-storage.md @@ -20,7 +20,7 @@ Store binary data using `Vec` (Rust), `List` (C#), `std::vector { // Delete existing avatar if present - ctx.db.userAvatar.userId.delete(userId); + ctx.db.user_avatar.userId.delete(userId); // Insert new avatar - ctx.db.userAvatar.insert({ + ctx.db.user_avatar.insert({ userId, mimeType, data, diff --git a/docs/docs/00200-core-concepts/00300-tables/00400-access-permissions.md b/docs/docs/00200-core-concepts/00300-tables/00400-access-permissions.md index 36005fa6c3f..666b68b5960 100644 --- a/docs/docs/00200-core-concepts/00300-tables/00400-access-permissions.md +++ b/docs/docs/00200-core-concepts/00300-tables/00400-access-permissions.md @@ -568,7 +568,7 @@ Use views to return a custom type that omits sensitive columns. The view reads f import {schema, t, table} from 'spacetimedb/server'; // Private table with sensitive data -const userAccount = table( +const user_account = table( { name: 'user_account' }, // Private by default { id: t.u64().primaryKey().autoInc(), @@ -581,7 +581,7 @@ const userAccount = table( } ); -const spacetimedb = schema({ userAccount }); +const spacetimedb = schema({ user_account }); export default spacetimedb; // Public type without sensitive columns @@ -597,7 +597,7 @@ export const my_profile = spacetimedb.view( t.option(publicUserProfile), (ctx) => { // Look up the caller's account by their identity (unique index) - const user = ctx.db.userAccount.identity.find(ctx.sender); + const user = ctx.db.user_account.identity.find(ctx.sender); if (!user) return null; return { id: user.id, diff --git a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md index e70bad128de..9069559e07d 100644 --- a/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md +++ b/docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md @@ -190,15 +190,15 @@ spacetimedb.reducer('deal_damage', { target: t.identity(), amount: t.u32() }, (c **Server (module) -- after:** ```typescript // 2.0 server -- explicitly publish events via an event table -const damageEvent = table({ name: 'damage_event', event: true }, { +const damage_event = table({ name: 'damage_event', event: true }, { target: t.identity(), amount: t.u32(), }) -// schema() takes an object: schema({ damageEvent }), never schema(damageEvent) -const spacetimedb = schema({ damageEvent }); +// schema() takes an object: schema({ damage_event }), never schema(damage_event) +const spacetimedb = schema({ damage_event }); export const dealDamage = spacetimedb.reducer({ target: t.identity(), amount: t.u32() }, (ctx, { target, amount }) => { - ctx.db.damageEvent.insert({ target, amount }); + ctx.db.damage_event.insert({ target, amount }); }); ``` @@ -1084,14 +1084,14 @@ SPACETIMEDB_REDUCER(my_reducer, ReducerContext ctx) { In 2.0 modules, only columns with a `.primaryKey()` constraint expose an `update` method, whereas previously, `.unique()` constraints also provided that method. The previous behavior led to confusion, as only updates which preserved the value in the primary key column resulted in `onUpdate` callbacks being invoked on the client. ```typescript -const myTable = table({ name: 'my_table' }, { +const my_table = table({ name: 'my_table' }, { id: t.u32().unique(), name: t.string(), }) // 1.0 -- REMOVED in 2.0 spacetimedb.reducer('my_reducer', ctx => { - ctx.db.myTable.id.update({ + ctx.db.my_table.id.update({ id: 1, name: "Foobar", }); @@ -1100,8 +1100,8 @@ spacetimedb.reducer('my_reducer', ctx => { // 2.0 -- Perform a delete followed by an insert // OR change the `.unique()` constraint into `.primaryKey()` constraint spacetimedb.reducer(ctx => { - ctx.db.myTable.id.delete(1); - ctx.db.myTable.insert({ + ctx.db.my_table.id.delete(1); + ctx.db.my_table.insert({ id: 1, name: "Foobar" }); @@ -1366,14 +1366,14 @@ spacetimedb.reducer('runMyTimer', myTimer.rowType, (ctx, timer) => { ``` ```typescript -const myTimer = table({ name: 'my_timer', scheduled: (): any => runMyTimer }, { +const my_timer = table({ name: 'my_timer', scheduled: (): any => runMyTimer }, { scheduledId: t.u64().primaryKey().autoInc(), scheduledAt: t.scheduleAt(), }); -const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) // 2.0 -- Can only be called by the database -export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Do stuff }) ``` @@ -1479,17 +1479,17 @@ In the rare event that you have a reducer or procedure which is intended to be i ```typescript -const myTimer = table({ name: 'my_timer', scheduled: (): any => runMyTimerPrivate }, { +const my_timer = table({ name: 'my_timer', scheduled: (): any => runMyTimerPrivate }, { scheduledId: t.u64().primaryKey().autoInc(), scheduledAt: t.scheduleAt(), }); -const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) +const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) -export const runMyTimerPrivate = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimerPrivate = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Do stuff... }); -export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => { +export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => { // Same logic as runMyTimerPrivate — extract to a helper if needed }); ```