Skip to content

Commit 4cbb7d3

Browse files
author
rain
committed
docs: fix TypeScript view cheat sheet syntax
1 parent 063b566 commit 4cbb7d3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,23 +600,23 @@ SPACETIMEDB_PROCEDURE(std::string, fetch_data, ProcedureContext ctx, std::string
600600
601601
```typescript
602602
// Return single row
603-
export const my_player = spacetimedb.view({ name: 'my_player' }, {}, t.option(player.rowType), ctx => {
603+
export const my_player = spacetimedb.view({ name: 'my_player', public: true }, t.option(player.rowType), ctx => {
604604
return ctx.db.player.identity.find(ctx.sender);
605605
});
606606
607607
// Return potentially multiple rows
608-
export const top_players = spacetimedb.view({ name: 'top_players' }, {}, t.array(player.rowType), ctx => {
608+
export const top_players = spacetimedb.view({ name: 'top_players', public: true }, t.array(player.rowType), ctx => {
609609
return ctx.db.player.score.filter(1000);
610610
});
611611
612612
// Perform a generic filter using the query builder.
613613
// Equivalent to `SELECT * FROM player WHERE score < 1000`.
614-
export const bottom_players = spacetimedb.view({ name: 'bottom_players' }, {}, t.array(player.rowType), ctx => {
614+
export const bottom_players = spacetimedb.view({ name: 'bottom_players', public: true }, t.array(player.rowType), ctx => {
615615
return ctx.from.player.where(p => p.score.lt(1000))
616616
});
617617
618618
// Count rows in a table.
619-
export const player_count = spacetimedb.anonymousView({ name: 'player_count' }, {}, t.array(t.row('PlayerCount', {
619+
export const player_count = spacetimedb.anonymousView({ name: 'player_count', public: true }, t.array(t.row('PlayerCount', {
620620
count: t.u64(),
621621
})), ctx => {
622622
return [{ count: ctx.db.player.count() }];

0 commit comments

Comments
 (0)