docs: fix daily docs audit findings - #5516
Conversation
# Conflicts: # skills/typescript-server/SKILL.md
|
|
||
| ```typescript | ||
| const damageEvent = table({ | ||
| const damage_event = table({ |
There was a problem hiding this comment.
No snake_case in TypeScript.
| - `--server`: target server | ||
| - `--break-clients`: allow breaking changes | ||
| - `--delete-data`: clear database data | ||
| - `--delete-data=<mode>`: clear database data (`always`, `on-conflict`, or `never`) |
There was a problem hiding this comment.
Is this a generated file?
| ); | ||
|
|
||
| const spacetimedb = schema({ players, playerLevels }); | ||
| const spacetimedb = schema({ players, player_levels }); |
There was a problem hiding this comment.
Should be camel case.
| (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)) { |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| // Track which chunks each player is subscribed to | ||
| const playerChunk = table( | ||
| const player_chunk = table( |
There was a problem hiding this comment.
Should be camel case.
| if (!player) return []; | ||
|
|
||
| const chunk = ctx.db.playerChunk.playerId.find(player.id); | ||
| const chunk = ctx.db.player_chunk.playerId.find(player.id); |
There was a problem hiding this comment.
Should be camel case.
| ); | ||
|
|
||
| const playerLevels = table( | ||
| const player_levels = table( |
There was a problem hiding this comment.
Should be camel case.
| ); | ||
|
|
||
| const spacetimedb = schema({ players, playerLevels }); | ||
| const spacetimedb = schema({ players, player_levels }); |
There was a problem hiding this comment.
Should be camel case.
| t.array(playerLevels.rowType), | ||
| (ctx) => ctx.from.playerLevels | ||
| t.array(player_levels.rowType), | ||
| (ctx) => ctx.from.player_levels |
There was a problem hiding this comment.
Should be camel case.
| export const levels_for_high_scorers = spacetimedb.anonymousView( | ||
| { name: 'levels_for_high_scorers', public: true }, | ||
| t.array(playerLevels.rowType), | ||
| t.array(player_levels.rowType), |
There was a problem hiding this comment.
Should be camel case.
| 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)) |
There was a problem hiding this comment.
Should be camel case.
| import { table, t, schema } from 'spacetimedb/server'; | ||
|
|
||
| const userAvatar = table( | ||
| const user_avatar = table( |
There was a problem hiding this comment.
Should be camel case.
| ); | ||
|
|
||
| const spacetimedb = schema({ userAvatar }); | ||
| const spacetimedb = schema({ user_avatar }); |
There was a problem hiding this comment.
Should be camel case.
| }, (ctx, { userId, mimeType, data }) => { | ||
| // Delete existing avatar if present | ||
| ctx.db.userAvatar.userId.delete(userId); | ||
| ctx.db.user_avatar.userId.delete(userId); |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| // Insert new avatar | ||
| ctx.db.userAvatar.insert({ | ||
| ctx.db.user_avatar.insert({ |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| // Private table with sensitive data | ||
| const userAccount = table( | ||
| const user_account = table( |
There was a problem hiding this comment.
Should be camel case.
| ); | ||
|
|
||
| const spacetimedb = schema({ userAccount }); | ||
| const spacetimedb = schema({ user_account }); |
There was a problem hiding this comment.
Should be camel case.
| (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); |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| const spacetimedb = schema({ | ||
| damageEvent, | ||
| damage_event, |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| // Publish the event | ||
| ctx.db.damageEvent.insert({ | ||
| ctx.db.damage_event.insert({ |
There was a problem hiding this comment.
Should be camel case.
| ```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 }, { |
There was a problem hiding this comment.
Should be camel case.
| // 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 }); |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| 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 }); |
There was a problem hiding this comment.
Should be camel case.
| // 1.0 -- REMOVED in 2.0 | ||
| spacetimedb.reducer('my_reducer', ctx => { | ||
| ctx.db.myTable.id.update({ | ||
| ctx.db.my_table.id.update({ |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| ```typescript | ||
| const myTable = table({ name: 'my_table' }, { | ||
| const my_table = table({ name: 'my_table' }, { |
There was a problem hiding this comment.
Should be camel case.
| spacetimedb.reducer(ctx => { | ||
| ctx.db.myTable.id.delete(1); | ||
| ctx.db.myTable.insert({ | ||
| ctx.db.my_table.id.delete(1); |
There was a problem hiding this comment.
Should be camel case.
| ctx.db.myTable.id.delete(1); | ||
| ctx.db.myTable.insert({ | ||
| ctx.db.my_table.id.delete(1); | ||
| ctx.db.my_table.insert({ |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| ```typescript | ||
| const myTimer = table({ scheduled: () => runMyTimer }, { | ||
| const my_timer = table({ name: 'my_timer', scheduled: (): any => runMyTimer }, { |
There was a problem hiding this comment.
Should be camel case.
| scheduledAt: t.scheduleAt(), | ||
| }); | ||
| const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) | ||
| const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) |
There was a problem hiding this comment.
Should be camel case.
|
|
||
| ```typescript | ||
| const myTimer = table({ scheduled: () => runMyTimerPrivate }, { | ||
| const my_timer = table({ name: 'my_timer', scheduled: (): any => runMyTimerPrivate }, { |
There was a problem hiding this comment.
Should be camel case.
| scheduledAt: t.scheduleAt(), | ||
| }); | ||
| const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table) | ||
| const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table) |
There was a problem hiding this comment.
Should be camel case.
Summary
--delete-dataexamples explicit while leaving interactive examples concise.conn.Reducers.On...events.(): any => ..., TypeScript scheduled table fields use snake_case in snake_case tables, and the C# scheduled-table example namesScheduledAtexplicitly.ctx.sender()/ctx.sender()) and the current Rustspacetimedb::Identityimport..AddDynamic(...), and disconnect callbacks receive(UDbConnection*, const FString&).Validation
git diff --checkpnpm --dir docs typecheck