30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
33// }
34
35// Database querying.
36
37function parseResultSet<T>(row: ResultSet): T[] {
1# SQLite - [Docs ↗](https://docs.val.town/std/sqlite)
2
3[SQLite](https://www.sqlite.org/) is a lightweight, standard database. Every Val Town account comes with its own private SQLite database that is accessible from any of your vals via [`std/sqlite`](https://www.val.town/v/std/sqlite).
4
5Val Town SQLite is powered by [Turso](https://turso.tech/).
9* [ORMs](https://docs.val.town/std/sqlite/orms)
10
11You may find these admin viewers helpful managing your database:
12
13* [SQLite Explorer](https://www.val.town/v/nbbaier/sqliteExplorerApp) (built in Val Town)
5/**
6 * Every Val Town account comes with its own private
7 * [SQLite database](https://www.sqlite.org/) that
8 * is accessible from any of your vals.
9 * ([Docs ↗](https://docs.val.town/std/sqlite))
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
3import dayjs from "npm:dayjs";
4
5const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
7
13
14export default async function(interval: Interval) {
15 const response = await notion.databases.query({
16 database_id: DATABASE_ID,
17 filter: {
18 and: [
40
41 const nextItem = {
42 parent: { database_id: DATABASE_ID },
43 properties: {
44 ...item.properties,
1WIP SQLite graph database based on https://github.com/dpapathanasiou/simple-graph
26 }
27
28 // generate a new random token, and saves it to the database
29 async generateToken(email: string): Promise<string> {
30 const { options: { tokenBytes, validDuration } } = this;
43 }
44
45 // check a token against the database that it's valid and not expired
46 // a valid match will return the id on record
47 // an expired match will return null
69 }
70
71 // remove expired/unclaimed tokens from the database. run this periodically to keep lookups fast
72 cull() {
73 this.deleteRows(`expires < ${this.now()}`);
34# How it works
35
36This val works by hashing the `userId` and using the resulting value to determine whether a flag should be enabled or disabled. In a 50% rollout, for example, the numeric hash of the `userId` is taken and divided by the maximum hash value. If the result is less than the rollout percentage, the flag is enabled. This allows for completely stateless feature flags, no database required.
37
38To prevent the same users getting features first all of the time, the flag name is prepended to the `userId` before hashing.