Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=database&page=93&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=database

Returns an array of strings in format "username" or "username/projectName"

Found 8428 results for "database"(7160ms)

openai-client.cursorrules2 matches

@cricks_unmixed4uโ€ขUpdated 3 weeks ago
198```
199โ”œโ”€โ”€ backend/
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering

openai-clientknowledge.md2 matches

@cricks_unmixed4uโ€ขUpdated 3 weeks ago
198```
199โ”œโ”€โ”€ backend/
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering

reactHonoStarterREADME.md1 match

@krishnaโ€ขUpdated 3 weeks ago
21## Further resources
22
23- [React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a bigger example project, with a SQLite database table, queries, client-side CSS, a favicon, and shared code that runs on both client and server.

sqliteExplorerApp1README.md1 match

@charmaineโ€ขUpdated 3 weeks ago
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

securityknowledge.md2 matches

@cricks_unmixed4uโ€ขUpdated 3 weeks ago
198```
199โ”œโ”€โ”€ backend/
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering

security.cursorrules2 matches

@cricks_unmixed4uโ€ขUpdated 3 weeks ago
198```
199โ”œโ”€โ”€ backend/
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering

hm-invoicesv1PLAN.md16 matches

@arfanโ€ขUpdated 3 weeks ago
5
6## Phase Completion Checklist
7- [x] Phase 1: Foundation & Database Setup
8- [x] Phase 2: Core Backend API
9- [x] Phase 3: Frontend Foundation
11- [ ] Phase 5: Polish & Optimization
12
13## Database Schema
14```sql
15CREATE TABLE invoices (
31```
32
33## Phase 1: Foundation & Database Setup
34**Goal**: Set up project structure and database with admin tools
35
36### Tasks:
40 - Create `shared/types.ts` for TypeScript interfaces
41
422. **Database Admin Tools**
43 - Create `admin/db-tools.tsx` for database management
44 - Create `admin/db-viewer.tsx` for raw data inspection
45 - Implement seed data with 16 placeholder vendors
46 - Add SQL commands section with common queries for manual operations
47 - Include link to database explorer: https://arfan25-admin-sqliteexplorerapp.val.run/
48
493. **Backend Database Layer**
50 - Create `backend/database/queries.ts` with CRUD operations
51 - Implement vendor management functions
52 - Implement invoice management functions
53
54### Deliverables:
55- Working admin interface for database management
56- Seeded database with 16 vendors
57- Complete CRUD operations for invoices and vendors
58
157
1583. **Performance & Polish**
159 - Optimize database queries
160 - Add pagination for large datasets
161 - Improve mobile responsiveness
172## Technical Stack
173- **Backend**: Hono.js for API routes
174- **Database**: SQLite with Val Town's sqlite service
175- **Frontend**: React 18.2.0 with TypeScript
176- **Styling**: DaisyUI + TailwindCSS with nord theme
186- **Dashboard**: Overview statistics and trends
187- **Filtering**: By vendor, type, status, date range
188- **Admin Tools**: Database management, seeding, and SQL command helpers
189- **Database Explorer**: Direct link to external SQLite explorer for advanced queries
190
191## Deployment Strategy
192Each phase will be deployable and functional, allowing for iterative development and testing. The admin tools will be available throughout for database management and debugging.

hm-invoicesv1VAL-TOWN-RULES.md33 matches

@arfanโ€ขUpdated 3 weeks ago
158```
159โ”œโ”€โ”€ admin/
160โ”‚ โ”œโ”€โ”€ db-viewer.tsx # Raw database table viewer
161โ”‚ โ”œโ”€โ”€ db-tools.tsx # Database management interface (seed, clear, status)
162โ”‚ โ””โ”€โ”€ README.md
163โ”œโ”€โ”€ backend/
164โ”‚ โ”œโ”€โ”€ database/
165โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions (CRUD operations)
166โ”‚ โ”‚ โ””โ”€โ”€ README.md
182โ””โ”€โ”€ shared/
183 โ”œโ”€โ”€ README.md
184 โ”œโ”€โ”€ config.ts # Database table names and shared config
185 โ””โ”€โ”€ utils.ts # Shared types and functions
186```
187
188### Admin Folder - Database Management
189
190The `admin/` folder contains standalone utilities for database management, separate from your main application logic:
191
192#### **db-viewer.tsx** - View raw database tables
193```ts
194import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
202```
203
204#### **db-tools.tsx** - Database management interface
205```ts
206import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
210const app = new Hono();
211
212// HTML interface for the database tools
213const HTML_INTERFACE = `
214<!DOCTYPE html>
217 <meta charset="UTF-8">
218 <meta name="viewport" content="width=device-width, initial-scale=1.0">
219 <title>Database Tools</title>
220 <script src="https://cdn.twind.style" crossorigin></script>
221</head>
222<body class="bg-gray-100 min-h-screen py-8">
223 <div class="max-w-2xl mx-auto bg-white rounded-lg shadow-md p-6">
224 <h1 class="text-3xl font-bold text-gray-800 mb-6">Database Tools</h1>
225
226 <div class="space-y-4 mb-6">
227 <div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
228 <h2 class="text-lg font-semibold text-blue-800 mb-2">Database Status</h2>
229 <p class="text-blue-700">Table: <code class="bg-blue-100 px-2 py-1 rounded">${TABLE_NAME}</code></p>
230 <button onclick="getStatus()" class="mt-2 bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded transition-colors">
234
235 <div class="bg-green-50 border border-green-200 rounded-lg p-4">
236 <h2 class="text-lg font-semibold text-green-800 mb-2">Seed Database</h2>
237 <p class="text-green-700 mb-2">Load initial data into the database.</p>
238 <button onclick="seedDatabase()" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded transition-colors">
239 Seed Data
240 </button>
250
251 <div class="bg-red-50 border border-red-200 rounded-lg p-4">
252 <h2 class="text-lg font-semibold text-red-800 mb-2">Clear Database</h2>
253 <p class="text-red-700 mb-2">Remove all data from the database.</p>
254 <button onclick="clearDatabase()" class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition-colors">
255 Clear Database
256 </button>
257 </div>
283 }
284
285 function seedDatabase() {
286 makeRequest('seed');
287 }
291 }
292
293 function clearDatabase() {
294 if (confirm('Are you sure you want to clear all data from the database?')) {
295 makeRequest('clear');
296 }
304app.get("/", (c) => c.html(HTML_INTERFACE));
305
306// Handle POST requests - perform database operations
307app.post("/", async (c) => {
308 const url = new URL(c.req.url);
315 return c.json({
316 success: true,
317 message: "Database status retrieved",
318 data: { table: TABLE_NAME, rowCount: count[0]?.count || 0 }
319 });
337 }
338
339 return c.json({ success: true, message: "Database seeded successfully", data: { seeded: seedData.length } });
340
341 case "force-seed":
352 }
353
354 return c.json({ success: true, message: "Database force re-seeded successfully", data: { seeded: newSeedData.length } });
355
356 case "clear":
357 await sqlite.execute(`DELETE FROM ${TABLE_NAME}`);
358 return c.json({ success: true, message: "Database cleared successfully" });
359
360 default:
373- Hono is the recommended API framework
374- Main entry point should be `main.tsx`
375- **Database Setup:** Use the admin utilities to handle table creation and seeding. Backend should focus on CRUD operations only
376- **Database Queries:** Keep all query functions in `backend/database/queries.ts` with proper TypeScript typing
377- **Static asset serving:** Use the utility functions to read and serve project files:
378 ```ts
406 ```
407
408### Database Patterns
409- **Setup:** Use admin utilities (`db-tools.tsx`) to create tables and seed initial data
410- **Development:** Use `db-viewer.tsx` to inspect database contents during development
411- **Reset:** Use `db-tools.tsx` to clear database when needed
412- **Backend Focus:** Backend database queries should only handle CRUD operations, not table creation
413- Change table names when modifying schemas rather than altering (update in `shared/config.ts`)
414- Export clear query functions with proper TypeScript typing

hm-invoicesv1main.tsx7 matches

@arfanโ€ขUpdated 3 weeks ago
3import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import {
5 initializeDatabase,
6 getAllVendors,
7 getVendorById,
14 seedVendors,
15 getTableCounts
16} from "./backend/database/queries.ts";
17import {
18 isValidStatus,
61});
62
63// Initialize database on startup
64try {
65 await initializeDatabase();
66 console.log("Database initialized successfully");
67} catch (error) {
68 console.error("Database initialization failed:", error);
69}
70
501});
502
503// GET /api/test - Test database functionality
504app.get("/api/test", async (c) => {
505 try {

hm-invoicesv1queries.ts2 matches

@arfanโ€ขUpdated 3 weeks ago
12} from "../../shared/types.ts";
13
14// Database initialization
15export async function initializeDatabase(): Promise<void> {
16 // Create vendors table
17 await sqlite.execute(`

customer-database-setup2 file matches

@stevenvapiโ€ขUpdated 1 week ago

prDatabase

@pdwโ€ขUpdated 2 weeks ago