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..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,6 +94,10 @@ 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/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 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 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 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