You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are in the process of moving from the `spacetimedb-docs` repo to the `docs` subdirectory of [SpacetimeDB](https://github.com/clockworklabs/SpacetimeDB). **Any new changes should be made there**. The `spacetimedb-docs` repo will only be updated on release. Apologies in advance for any sharp edges while the migration is in progress.
1
+
# Website
3
2
4
-
## SpacetimeDB Documentation
3
+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
5
4
6
-
This repository contains the markdown files which are used to display documentation on our [website](https://spacetimedb.com/docs).
5
+
### Installation
7
6
8
-
### Making Edits
9
-
10
-
To make changes to our docs, you can open a pull request in this repository. You can typically edit the files directly using the GitHub web interface, but you can also clone our repository and make your edits locally. To do this you can follow these instructions:
6. Go to our GitHub and open a PR that references your branch in your fork on your GitHub
25
+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
36
26
37
-
> NOTE! If you make a change to `nav.ts` you will have to run `npm run build` to generate a new `docs/nav.js` file.
27
+
### Deployment
38
28
39
-
#### CLI Reference Section
40
-
1. Run `cargo run --features markdown-docs -p spacetimedb-cli > docs/cli-reference.md`
41
-
2. Run `pnpm format`
29
+
Using SSH:
42
30
43
-
### Checking Links
31
+
```
32
+
$ USE_SSH=true yarn deploy
33
+
```
44
34
45
-
We have a CI job which validates internal links. You can run it locally with `npm run check-links`. This will print any internal links (i.e. links to other docs pages) whose targets do not exist, including fragment links (i.e. `#`-ey links to anchors).
35
+
Not using SSH:
46
36
47
-
## License
37
+
```
38
+
$ GIT_USER=<Your GitHub username> yarn deploy
39
+
```
48
40
49
-
This documentation repository is licensed under Apache 2.0. See LICENSE.txt for more details.
41
+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -21,11 +25,18 @@ SpacetimeDB is a full-featured relational database system that lets you run your
21
25
This means that you can write your entire application in a single language and deploy it as a single binary. No more microservices, no more containers, no more Kubernetes, no more Docker, no more VMs, no more DevOps, no more infrastructure, no more ops, no more servers.
This is similar to ["smart contracts"](https://en.wikipedia.org/wiki/Smart_contract), except that SpacetimeDB is a **database** and has nothing to do with blockchain. Because it isn't a blockchain, it can be dramatically faster than many "smart contract" systems.
@@ -36,23 +47,6 @@ SpacetimeDB is optimized for maximum speed and minimum latency, rather than batc
36
47
37
48
Speed and latency is achieved by holding all of your application state in memory, while persisting data to a commit log which is used to recover data after restarts and system crashes.
The above illustrates the workflow when using SpacetimeDB.
50
-
51
-
* All client-side reads happen with the data view that is cached locally.
52
-
* Client-side subscriptions tell the server what data client cares about and wants to be synced within its data view. Changes to data will be pushed by the server to the client cache.
53
-
* RLS filters restrict the data view server-side before subscriptions are evaluated. These filters can be used for access control or client scoping.
54
-
* Reducers are effectively async RPC's. The request is sent off and if the results of that reducer makes changes to data, it will be written to the database directly. As a result of that, if those changes make it through the two layers above, then the client will see the result when it queries its local cache.
55
-
56
50
## State Mirroring
57
51
58
52
SpacetimeDB can generate client code in a [variety of languages](#client-side-sdks). This creates a client library custom-designed to talk to your database. It provides easy-to-use interfaces for connecting to the database and submitting requests. It can also **automatically mirror state** from your database to client applications.
@@ -83,9 +77,11 @@ SpacetimeDB was designed first and foremost as the backend for multiplayer Unity
83
77
## Key architectural concepts
84
78
85
79
### Host
80
+
86
81
A SpacetimeDB **host** is a server that hosts [databases](#database). You can run your own host, or use the SpacetimeDB maincloud. Many databases can run on a single host.
87
82
88
83
### Database
84
+
89
85
A SpacetimeDB **database** is an application that runs on a [host](#host).
90
86
91
87
A database exports [tables](#table), which store data, and [reducers](#reducer), which allow [clients](#client) to make requests.
@@ -95,8 +91,27 @@ A database's schema and business logic is specified by a piece of software calle
95
91
(Technically, a SpacetimeDB module is a [WebAssembly module](https://developer.mozilla.org/en-US/docs/WebAssembly) that imports a specific low-level [WebAssembly ABI](/docs/webassembly-abi) and exports a small number of special functions. However, the SpacetimeDB [server-side libraries](#module-libraries) hide these low-level details. As a developer, writing a module is mostly like writing any other C# or Rust application, except for the fact that a [special CLI tool](/install) is used to deploy the application.)
96
92
97
93
### Table
94
+
98
95
A SpacetimeDB **table** is a SQL database table. Tables are declared in a module's native language. For instance, in C#, a table is declared like so:
99
96
97
+
<TabsgroupId="syntax"queryString>
98
+
99
+
<TabItemvalue="rust"label="Rust">
100
+
101
+
```rust
102
+
#[spacetimedb::table(name = players, public)]
103
+
pubstructPlayer {
104
+
#[primary_key]
105
+
id:u64,
106
+
name:String,
107
+
age:u32,
108
+
user:Identity,
109
+
}
110
+
```
111
+
112
+
</TabItem>
113
+
<TabItemvalue="csharp"label="C#">
114
+
100
115
```csharp
101
116
[SpacetimeDB.Table(Name="players", Public=true)]
102
117
publicpartialstructPlayer
@@ -108,28 +123,23 @@ public partial struct Player
108
123
Identityuser;
109
124
}
110
125
```
111
-
<!-- TODO: switchable language widget.
112
-
```rust
113
-
#[spacetimedb::table(name = players, public)]
114
-
pub struct Player {
115
-
#[primary_key]
116
-
id: u64,
117
-
name: String,
118
-
age: u32,
119
-
user: Identity,
120
-
}
121
-
```
122
-
-->
126
+
127
+
</TabItem>
128
+
129
+
</Tabs>
123
130
124
131
The contents of a table can be read and updated by [reducers](#reducer).
125
132
Tables marked `public` can also be read by [clients](#client).
126
133
127
134
### Reducer
135
+
128
136
A **reducer** is a function exported by a [database](#database).
129
137
Connected [clients](#client-side-sdks) can call reducers to interact with the database.
130
138
This is a form of [remote procedure call](https://en.wikipedia.org/wiki/Remote_procedure_call).
While SpacetimeDB doesn't support nested transactions,
209
228
a reducer can [schedule another reducer](https://docs.rs/spacetimedb/latest/spacetimedb/attr.reducer.html#scheduled-reducers) to run at an interval,
210
229
or at a specific time.
211
-
:::
212
-
:::server-csharp
230
+
231
+
</TabItem>
232
+
<TabItemvalue="csharp"label="C#">
233
+
213
234
```csharp
214
235
[SpacetimeDB.Reducer]
215
236
publicstaticvoidHello(ReducerContextctx)
@@ -227,13 +248,16 @@ public static void World(ReducerContext ctx)
227
248
// ...
228
249
}
229
250
```
251
+
230
252
While SpacetimeDB doesn't support nested transactions,
231
253
a reducer can [schedule another reducer](/docs/modules/c-sharp#scheduled-reducers) to run at an interval,
232
254
or at a specific time.
233
-
:::
234
255
256
+
</TabItem>
257
+
</Tabs>
235
258
236
259
### Client
260
+
237
261
A **client** is an application that connects to a [database](#database). A client logs in using an [identity](#identity) and receives an [connection id](#connectionid) to identify the connection. After that, it can call [reducers](#reducer) and query public [tables](#table).
238
262
239
263
Clients are written using the [client-side SDKs](#client-side-sdks). The `spacetime` CLI tool allows automatically generating code that works with the client-side SDKs to talk to a particular database.
0 commit comments