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=328&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 3476 results for "database"(1164ms)

tenseRoseTiglonREADME.md1 match

@MichaelNollox•Updated 8 months ago
1# VALL-E
2
3LLM code generation for vals! Make apps with a frontend, backend, and database.
4
5It's a bit of work to get this running, but it's worth it.

VALLEREADME.md1 match

@MichaelNollox•Updated 8 months ago
1# VALL-E
2
3LLM code generation for vals! Make apps with a frontend, backend, and database.
4
5It's a bit of work to get this running, but it's worth it.

blobmain.tsx1 match

@nichoth•Updated 8 months ago
8import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
9
10// Initialize the database
11await sqlite.execute(`
12 CREATE TABLE IF NOT EXISTS blobs (

lucia_demomain.tsx2 matches

@stevekrouse•Updated 8 months ago
26 interface Register {
27 Lucia: typeof lucia;
28 DatabaseUserAttributes: DatabaseUserAttributes;
29 }
30}
31
32interface DatabaseUserAttributes {
33 username: string;
34}

lucia_adapter_basemain.tsx22 matches

@stevekrouse•Updated 8 months ago
1import type {
2 Adapter,
3 DatabaseSession,
4 DatabaseUser,
5 RegisteredDatabaseSessionAttributes,
6 RegisteredDatabaseUserAttributes,
7} from "npm:lucia";
8
34 public async getSessionAndUser(
35 sessionId: string,
36 ): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]> {
37 const [databaseSession, databaseUser] = await Promise.all([
38 this.getSession(sessionId),
39 this.getUserFromSessionId(sessionId),
40 ]);
41 return [databaseSession, databaseUser];
42 }
43
44 public async getUserSessions(userId: string): Promise<DatabaseSession[]> {
45 const result = await this.controller.getAll<SessionSchema>(
46 `SELECT * FROM ${this.escapedSessionTableName} WHERE user_id = ?`,
48 );
49 return result.map((val) => {
50 return transformIntoDatabaseSession(val);
51 });
52 }
53
54 public async setSession(databaseSession: DatabaseSession): Promise<void> {
55 const value: SessionSchema = {
56 id: databaseSession.id,
57 user_id: databaseSession.userId,
58 expires_at: Math.floor(databaseSession.expiresAt.getTime() / 1000),
59 ...databaseSession.attributes,
60 };
61 const entries = Object.entries(value).filter(([_, v]) => v !== undefined);
87 }
88
89 private async getSession(sessionId: string): Promise<DatabaseSession | null> {
90 const result = await this.controller.get<SessionSchema>(
91 `SELECT * FROM ${this.escapedSessionTableName} WHERE id = ?`,
93 );
94 if (!result) return null;
95 return transformIntoDatabaseSession(result);
96 }
97
98 private async getUserFromSessionId(sessionId: string): Promise<DatabaseUser | null> {
99 const result = await this.controller.get<UserSchema>(
100 `SELECT ${this.escapedUserTableName}.* FROM ${this.escapedSessionTableName} INNER JOIN ${this.escapedUserTableName} ON ${this.escapedUserTableName}.id = ${this.escapedSessionTableName}.user_id WHERE ${this.escapedSessionTableName}.id = ?`,
102 );
103 if (!result) return null;
104 return transformIntoDatabaseUser(result);
105 }
106}
117}
118
119interface SessionSchema extends RegisteredDatabaseSessionAttributes {
120 id: string;
121 user_id: string;
123}
124
125interface UserSchema extends RegisteredDatabaseUserAttributes {
126 id: string;
127}
128
129function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
130 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
131 return {
137}
138
139function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
140 const { id, ...attributes } = raw;
141 return {

valleGetValsContextWindowmain.tsx1 match

@janpaul123•Updated 9 months ago
116 {
117 name: "Use Val Town SQLite to store data",
118 prompt: "Write a val that uses an SQLite database",
119 code: `import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
120

featureflagsREADME.md1 match

@samwho•Updated 9 months ago
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.

myTablemain.tsx1 match

@hello_mikkie•Updated 9 months ago
6 tableName: "tblRJj6ty16uR9QhC",
7});
8// Sample data from: https://blog.airtable.com/database-vs-spreadsheet/
9const results = await airtable.select();
10console.log(results);

blobWithSqlitemain.tsx1 match

@yawnxyz•Updated 9 months ago
8import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
9
10// Initialize the database
11await sqlite.execute(`
12 CREATE TABLE IF NOT EXISTS blobs (

sqliteAdminREADME.md1 match

@kamalnrf•Updated 9 months 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

bookmarksDatabase

@s3thi•Updated 2 months ago

sqLiteDatabase1 file match

@ideofunk•Updated 5 months ago