Skip to content

Commit 9dc58c7

Browse files
author
rain
committed
docs: align scheduled function examples
1 parent 7f66bc4 commit 9dc58c7

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ import { schema, table, t } from 'spacetimedb/server';
327327
const scheduled_task = table(
328328
{ name: 'scheduled_task', scheduled: (): any => send_reminder },
329329
{
330-
taskId: t.u64().primaryKey().autoInc(),
331-
scheduledAt: t.scheduleAt(),
330+
task_id: t.u64().primaryKey().autoInc(),
331+
scheduled_at: t.scheduleAt(),
332332
message: t.string(),
333333
}
334334
);
@@ -349,14 +349,14 @@ using SpacetimeDB;
349349

350350
public static partial class Module
351351
{
352-
[SpacetimeDB.Table(Accessor = "ScheduledTask", Scheduled = nameof(SendReminder))]
352+
[SpacetimeDB.Table(Accessor = "ScheduledTask", Scheduled = nameof(SendReminder), ScheduledAt = nameof(ScheduledAt))]
353353
public partial struct ScheduledTask
354354
{
355355
[SpacetimeDB.PrimaryKey]
356356
[SpacetimeDB.AutoInc]
357-
public ulong taskId;
358-
public ScheduleAt scheduledAt;
359-
public string message;
357+
public ulong TaskId;
358+
public ScheduleAt ScheduledAt;
359+
public string Message;
360360
}
361361

362362
[SpacetimeDB.Reducer]

docs/docs/00300-resources/00100-how-to/00600-migrating-to-2.0.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,14 +1366,14 @@ spacetimedb.reducer('runMyTimer', myTimer.rowType, (ctx, timer) => {
13661366
```
13671367

13681368
```typescript
1369-
const myTimer = table({ scheduled: () => runMyTimer }, {
1370-
scheduledId: t.u64().primaryKey().autoInc(),
1371-
scheduledAt: t.scheduleAt(),
1369+
const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimer }, {
1370+
scheduled_id: t.u64().primaryKey().autoInc(),
1371+
scheduled_at: t.scheduleAt(),
13721372
});
1373-
const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table)
1373+
const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table)
13741374

13751375
// 2.0 -- Can only be called by the database
1376-
export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => {
1376+
export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => {
13771377
// Do stuff
13781378
})
13791379
```
@@ -1479,17 +1479,17 @@ In the rare event that you have a reducer or procedure which is intended to be i
14791479
<TabItem value="typescript" label="TypeScript">
14801480
14811481
```typescript
1482-
const myTimer = table({ scheduled: () => runMyTimerPrivate }, {
1483-
scheduledId: t.u64().primaryKey().autoInc(),
1484-
scheduledAt: t.scheduleAt(),
1482+
const my_timer = table({ name: "my_timer", scheduled: (): any => runMyTimerPrivate }, {
1483+
scheduled_id: t.u64().primaryKey().autoInc(),
1484+
scheduled_at: t.scheduleAt(),
14851485
});
1486-
const spacetimedb = schema({ myTimer }); // schema({ table }), never schema(table)
1486+
const spacetimedb = schema({ my_timer }); // schema({ table }), never schema(table)
14871487
1488-
export const runMyTimerPrivate = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => {
1488+
export const runMyTimerPrivate = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => {
14891489
// Do stuff...
14901490
});
14911491
1492-
export const runMyTimer = spacetimedb.reducer({ arg: myTimer.rowType }, (ctx, { arg }) => {
1492+
export const runMyTimer = spacetimedb.reducer({ arg: my_timer.rowType }, (ctx, { arg }) => {
14931493
// Same logic as runMyTimerPrivate — extract to a helper if needed
14941494
});
14951495
```

0 commit comments

Comments
 (0)