Skip to content

Commit

Permalink
Release v0.12.0 docs updates (#97)
Browse files Browse the repository at this point in the history
* Update quickstart.md (#81)

Revert the find_by changes in rust which were never made.

* Update Rust Quickstart to use correct function to find User (#80)

Update quickstart.md

* Explicitly remind the reader to start the server (#43)

* Fix broken tutorial package link (#86)

* prettier (#85)

Push

* Update quickstart.md (#84)

* Fix typo in modules/rust/index.md (#83)

Person -> Unique (because that belongs to `Unique` table)

* Update part-2b-c-sharp.md (#75)

The intent is to throw an exception if the player already exists, not the other way 'round.

* Fixed code examples in rust reference regarding insertion (#42)

* Rust client quickstart updated for 0.12 (#92)

* Rust client updated for 0.12

* Small update

* More updates

* Final pass

---------

Co-authored-by: John Detter <[email protected]>

* I didn't notice that auto-merge was enabled, so here's my review (#94)

* Update Rust SDK ref for the new SDK (#93)

* Updated rust quickstart for 0.12 (#88)

* Updated rust quickstart for 0.12

* Suggested tweaks

---------

Co-authored-by: John Detter <[email protected]>

* Update rust index page for 0.12 (#89)

* Updated rust quickstart for 0.12

* Suggested tweaks

* Initial updates to the index file

* More updates to index, rolled back changes from another PR I'm working on

* Small improvements

---------

Co-authored-by: John Detter <[email protected]>

---------

Co-authored-by: Tyler Cloutier <[email protected]>
Co-authored-by: Mats Bennervall <[email protected]>
Co-authored-by: ike709 <[email protected]>
Co-authored-by: John Detter <[email protected]>
Co-authored-by: Puru Vijay <[email protected]>
Co-authored-by: Egor Gavrilov <[email protected]>
Co-authored-by: Arrel Neumiller <[email protected]>
Co-authored-by: Muthsera <[email protected]>
Co-authored-by: John Detter <[email protected]>
Co-authored-by: Phoebe Goldman <[email protected]>
Co-authored-by: Zeke Foppa <[email protected]>
  • Loading branch information
12 people authored Oct 4, 2024
1 parent 78c51b0 commit f859208
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 1,451 deletions.
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"arrowParens": "avoid",
"jsxSingleQuote": false,
"trailingComma": "es5",
"endOfLine": "auto",
"printWidth": 80
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ git clone ssh://[email protected]/<username>/spacetime-docs
git add .
git commit -m "A specific description of the changes I made and why"
```

5. Push your changes to your fork as a branch

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ You are ready to start developing SpacetimeDB modules. See below for a quickstar
### Client

- [Rust](/docs/sdks/rust/quickstart)
- [C# (Standalone)](/docs/sdks/c-sharp/quickstart)
- [C# (Standalone)](/docs/sdks/c-sharp/quickstart)
- [C# (Unity)](/docs/unity/part-1)
- [Typescript](/docs/sdks/typescript/quickstart)
72 changes: 36 additions & 36 deletions docs/http/database.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/http/energy.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Accessible through the CLI as `spacetime energy set-balance <balance> <identity>

#### Required Headers

| Name | Value |
| --------------- | ------------------------------------------------------------------------------------------- |
| Name | Value |
| --------------- | --------------------------------------------------------------- |
| `Authorization` | A Spacetime token [encoded as Basic authorization](/docs/http). |

#### Returns
Expand Down
12 changes: 6 additions & 6 deletions docs/http/identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ Generate a short-lived access token which can be used in untrusted contexts, e.g

#### Required Headers

| Name | Value |
| --------------- | ------------------------------------------------------------------------------------------- |
| Name | Value |
| --------------- | --------------------------------------------------------------- |
| `Authorization` | A Spacetime token [encoded as Basic authorization](/docs/http). |

#### Returns
Expand Down Expand Up @@ -107,8 +107,8 @@ Accessible through the CLI as `spacetime identity set-email <identity> <email>`.

#### Required Headers

| Name | Value |
| --------------- | ------------------------------------------------------------------------------------------- |
| Name | Value |
| --------------- | --------------------------------------------------------------- |
| `Authorization` | A Spacetime token [encoded as Basic authorization](/docs/http). |

## `/identity/:identity/databases GET`
Expand Down Expand Up @@ -145,8 +145,8 @@ Verify the validity of an identity/token pair.

#### Required Headers

| Name | Value |
| --------------- | ------------------------------------------------------------------------------------------- |
| Name | Value |
| --------------- | --------------------------------------------------------------- |
| `Authorization` | A Spacetime token [encoded as Basic authorization](/docs/http). |

#### Returns
Expand Down
21 changes: 10 additions & 11 deletions docs/modules/c-sharp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static partial class Module
{
// We can skip (or explicitly set to zero) auto-incremented fields when creating new rows.
var person = new Person { Name = name, Age = age };

// `Insert()` method is auto-generated and will insert the given row into the table.
person.Insert();
// After insertion, the auto-incremented fields will be populated with their actual values.
Expand Down Expand Up @@ -120,7 +120,6 @@ And a couple of special custom types:
- `Identity` (`SpacetimeDB.Runtime.Identity`) - a unique identifier for each user; internally a byte blob but can be printed, hashed and compared for equality.
- `Address` (`SpacetimeDB.Runtime.Address`) - an identifier which disamgibuates connections by the same `Identity`; internally a byte blob but can be printed, hashed and compared for equality.


#### Custom types

`[SpacetimeDB.Type]` attribute can be used on any `struct`, `class` or an `enum` to mark it as a SpacetimeDB type. It will implement serialization and deserialization for values of this type so that they can be stored in the database.
Expand Down Expand Up @@ -245,10 +244,10 @@ public partial struct Person
// Finds a row in the table with the given value in the `Id` column and returns it, or `null` if no such row exists.
public static Person? FindById(int id);

// Deletes a row in the table with the given value in the `Id` column and returns `true` if the row was found and deleted, or `false` if no such row exists.
public static bool DeleteById(int id);

// Updates a row in the table with the given value in the `Id` column and returns `true` if the row was found and updated, or `false` if no such row exists.
public static bool UpdateById(int oldId, Person newValue);
}
Expand Down Expand Up @@ -295,22 +294,22 @@ public static void PrintInfo(ReducerContext e)
}
```


### Scheduler Tables

Tables can be used to schedule a reducer calls either at a specific timestamp or at regular intervals.

```csharp
public static partial class Timers
{

// The `Scheduled` attribute links this table to a reducer.
[SpacetimeDB.Table(Scheduled = nameof(SendScheduledMessage))]
public partial struct SendMessageTimer
{
public string Text;
}


// Define the reducer that will be invoked by the scheduler table.
// The first parameter is always `ReducerContext`, and the second parameter is an instance of the linked table struct.
[SpacetimeDB.Reducer]
Expand Down Expand Up @@ -354,10 +353,10 @@ public static partial class Timers
public partial struct SendMessageTimer
{
public string Text; // fields of original struct
[SpacetimeDB.Column(ColumnAttrs.PrimaryKeyAuto)]
public ulong ScheduledId; // unique identifier to be used internally
public SpacetimeDB.ScheduleAt ScheduleAt; // Scheduling details (Time or Inteval)
}
}
Expand All @@ -375,10 +374,9 @@ These are four special kinds of reducers that can be used to respond to module l
- `ReducerKind.Connect` - this reducer will be invoked when a client connects to the database.
- `ReducerKind.Disconnect` - this reducer will be invoked when a client disconnects from the database.


Example:

```csharp
````csharp
[SpacetimeDB.Reducer(ReducerKind.Init)]
public static void Init()
{
Expand All @@ -402,3 +400,4 @@ public static void OnDisconnect(DbEventArgs ctx)
{
Log($"{ctx.Sender} has disconnected.");
}```
````
8 changes: 4 additions & 4 deletions docs/modules/c-sharp/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ If you haven't already, start by [installing SpacetimeDB](/install). This will i
Next we need to [install .NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) so that we can build and publish our module.

You may already have .NET 8 and can be checked:

```bash
dotnet --list-sdks
```
Expand Down Expand Up @@ -50,7 +51,7 @@ spacetime init --lang csharp server

## Declare imports

`spacetime init` generated a few files:
`spacetime init` generated a few files:

1. Open `server/StdbModule.csproj` to generate a .sln file for intellisense/validation support.
2. Open `server/Lib.cs`, a trivial module.
Expand Down Expand Up @@ -81,7 +82,6 @@ To get our chat server running, we'll need to store two kinds of data: informati

For each `User`, we'll store their `Identity`, an optional name they can set to identify themselves to other users, and whether they're online or not. We'll designate the `Identity` as our primary key, which enforces that it must be unique, indexes it for faster lookup, and allows clients to track updates.


In `server/Lib.cs`, add the definition of the table `User` to the `Module` class:

```csharp
Expand Down Expand Up @@ -281,10 +281,10 @@ npm i wasm-opt -g
You can use the CLI (command line interface) to run reducers. The arguments to the reducer are passed in JSON format.

```bash
spacetime call <module-name> send_message "Hello, World!"
spacetime call <module-name> SendMessage "Hello, World!"
```

Once we've called our `send_message` reducer, we can check to make sure it ran by running the `logs` command.
Once we've called our `SendMessage` reducer, we can check to make sure it ran by running the `logs` command.

```bash
spacetime logs <module-name>
Expand Down
Loading

0 comments on commit f859208

Please sign in to comment.