Skip to content

Commit ff18253

Browse files
authored
Mikec/visual examples (#44)
* wip * wip adding a vite project * fixed quotes issues * fixed typechecking failing on tests by excluding * using mantine instead of tailwind * wip * wip example ui * fixing error in this example * wip design * added some nicer styling * wip * tidy * responsive stats page * fixed sidebar * better styles * wip * wip resetting * clearing issue? * tests pass but ts failing * removing any * fixed tests * added a couple of basic tests * replicated the clearAll issue * fixed clear issue * tidy tests a bit more * tidied up vron * improved photos examepl * improved shuffle example * wip baseline tests * bounds now optional * wip optional bounds * tidied tests up a bunch * didnt need to be partial * tests fixed ts not * tidy * tidying up the visual examples some more * now adding a structured dump too * wip * using simpler tree * tweaked how its shown * back to basics on btree demo * wip getting the trees and nodes * wip app shelll * tidy up * tidied up a bit * proper sizing * more wip on the btree view * parallel * cron reset of btree * fixed runtime issue * makeing adding a photo random * bumped readme * fixed uneaven header * split sections up a bit * paginated leaderbaord * better leaderboard layout * small refactors * suffle page aside * better splitting up of the components with asides * bounds optional * tidy up the page lookup * tidied up a couple of things * also allowing editing on the leaderboard rows * polishing with a convex logo * removing the index and using triggers * added some more comments * better variable names * fixed example tests * fixed npm install * added thumb to readme * removed package lock as suggested * fixing setup script in the example * using the table validator instead * preventing the resetAndSeed from potentially timing out * lowered ui function * simplified imports * nicer flowing of code
1 parent 6479bc1 commit ff18253

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+10174
-2235
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
This Convex component calculates count and sums of values for efficient
88
aggregation.
99

10+
[![Efficient COUNT, SUM, MAX with the Aggregate Component](https://thumbs.video-to-markdown.com/9c06ce06.jpg)](https://youtu.be/YD3nW_PtHWA)
11+
1012
Suppose you have a leaderboard of game scores. These are some operations
1113
that the Aggregate component makes easy and efficient:
1214

@@ -307,9 +309,7 @@ const randomize = new TableAggregate<{
307309
Key: null;
308310
DataModel: DataModel;
309311
TableName: "mytable";
310-
}>(components.aggregate, {
311-
sortKey: (doc) => null,
312-
});
312+
}>(components.aggregate, { sortKey: (doc) => null });
313313
```
314314

315315
Without sorting, all documents are ordered by their `_id` which is generally
@@ -331,10 +331,10 @@ For this example, imagine you have a table of photo albums.
331331
```ts
332332
// convex/schema.ts
333333
defineSchema({
334-
photos: defineTable({
335-
album: v.string(),
336-
url: v.string(),
337-
}).index("by_album_creation_time", ["album"]),
334+
photos: defineTable({ album: v.string(), url: v.string() }).index(
335+
"by_album_creation_time",
336+
["album"]
337+
),
338338
});
339339
```
340340

@@ -390,10 +390,9 @@ import { DataModel } from "./_generated/dataModel";
390390
import { DirectAggregate } from "@convex-dev/aggregate";
391391
// Note the `id` should be unique to be a tie-breaker in case two data points
392392
// have the same key.
393-
const aggregate = new DirectAggregate<{
394-
Key: number;
395-
Id: string;
396-
}>(components.aggregate);
393+
const aggregate = new DirectAggregate<{ Key: number; Id: string }>(
394+
components.aggregate
395+
);
397396

398397
// within a mutation, add values to be aggregated
399398
await aggregate.insert(ctx, { key, id });

example/.cursor/rules/convex_rules.mdc

Lines changed: 676 additions & 0 deletions
Large diffs are not rendered by default.

example/.gitignore

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
!**/glob-import/dir/node_modules
2-
.DS_Store
3-
.idea
4-
*.cpuprofile
5-
*.local
1+
# Logs
2+
logs
63
*.log
7-
/.vscode/
8-
/docs/.vitepress/cache
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
911
dist
1012
dist-ssr
11-
explorations
12-
node_modules
13-
playground-temp
14-
temp
15-
TODOs.md
16-
.eslintcache
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

example/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# Example app
1+
# Example App
22

3-
See convex/config.ts and convex/leaderboard.ts for example usages of the
4-
Aggregate component.
3+
## To run the examples
4+
5+
Once you have cloned this repo, **from the root of the repo**:
6+
7+
```bash
8+
npm run setup
9+
```
10+
11+
You will need to follow the instructions to setup a Convex project. Once done you should be able to open the example at `http://localhost:5173/`

0 commit comments

Comments
 (0)