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))
403 const SCHEMA_VERSION = 4;
404
405 // Initialize database with additional fields
406 await sqlite.execute(`
407 CREATE TABLE IF NOT EXISTS ${KEY}_users_${SCHEMA_VERSION} (
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
236 console.error("Error creating tables:", createTableError);
237 return new Response(JSON.stringify({
238 error: 'Database initialization failed',
239 details: createTableError.toString()
240 }), {
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
1Downloads an export of all my bookmarks from Raindrop.io and syncs the URLs and created dates into an SQLite database. Runs every day.
2
3Used to power https://www.val.town/v/s3thi/stumbleDrop. Database schema is managed using https://www.val.town/v/s3thi/bookmarksDatabase.
3Powered by:
4
5- https://www.val.town/v/s3thi/bookmarksDatabase to define the schema for the SQLite database that holds a copy of my bookmarks
6- https://www.val.town/v/s3thi/syncBookmarks to sync bookmarks from Raindrop.io on a set interval
1import { generateCode } from "./backend/generate-code";
2import { createTables } from "./database/migrations";
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
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
14}
15
16// DatabaseContent component
17function DatabaseContent({ data }: { data: Action[] }) {
18 return (
19 <pre className="bg-white dark:bg-gray-800 p-4 rounded-lg shadow-md overflow-auto dark:text-white border border-gray-200 dark:border-gray-700">{JSON.stringify(data, null, 2)}</pre>
219 className="bg-green-500 hover:bg-green-600 text-white font-medium py-2 px-4 rounded-md mb-4 transition duration-200 dark:bg-green-600 dark:hover:bg-green-700"
220 >
221 {showDbContent ? 'Hide' : 'Show'} Database Content
222 </button>
223 {showDbContent && (
224 <div className="mt-4">
225 <DatabaseContent data={dbContent} />
226 </div>
227 )}