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/$%7Bart_info.art.src%7D?q=database&page=363&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 3893 results for "database"(2289ms)

luciaValtownSqlitemain.tsx22 matches

@yawnxyz•Updated 8 months ago
6import type {
7 Adapter,
8 DatabaseSession,
9 DatabaseUser,
10 RegisteredDatabaseSessionAttributes,
11 RegisteredDatabaseUserAttributes,
12} from "npm:lucia";
13
23}
24
25interface SessionSchema extends RegisteredDatabaseSessionAttributes {
26 id: string;
27 user_id: string;
29}
30
31interface UserSchema extends RegisteredDatabaseUserAttributes {
32 id: string;
33}
59 public async getSessionAndUser(
60 sessionId: string,
61 ): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]> {
62 const [databaseSession, databaseUser] = await Promise.all([
63 this.getSession(sessionId),
64 this.getUserFromSessionId(sessionId),
65 ]);
66 return [databaseSession, databaseUser];
67 }
68
69 public async getUserSessions(userId: string): Promise<DatabaseSession[]> {
70 const result = await this.controller.getAll<SessionSchema>(
71 `SELECT * FROM ${this.escapedSessionTableName} WHERE user_id = ?`,
72 [userId],
73 );
74 return result.map((val) => transformIntoDatabaseSession(val));
75 }
76
77 public async setSession(databaseSession: DatabaseSession): Promise<void> {
78 const value: SessionSchema = {
79 id: databaseSession.id,
80 user_id: databaseSession.userId,
81 expires_at: Math.floor(databaseSession.expiresAt.getTime() / 1000),
82 ...databaseSession.attributes,
83 };
84 const entries = Object.entries(value).filter(([_, v]) => v !== undefined);
108 }
109
110 private async getSession(sessionId: string): Promise<DatabaseSession | null> {
111 const result = await this.controller.get<SessionSchema>(
112 `SELECT * FROM ${this.escapedSessionTableName} WHERE id = ?`,
114 );
115 if (!result) return null;
116 return transformIntoDatabaseSession(result);
117 }
118
119 private async getUserFromSessionId(sessionId: string): Promise<DatabaseUser | null> {
120 const result = await this.controller.get<UserSchema>(
121 `SELECT ${this.escapedUserTableName}.* FROM ${this.escapedSessionTableName} INNER JOIN ${this.escapedUserTableName} ON ${this.escapedUserTableName}.id = ${this.escapedSessionTableName}.user_id WHERE ${this.escapedSessionTableName}.id = ?`,
123 );
124 if (!result) return null;
125 return transformIntoDatabaseUser(result);
126 }
127}
236}
237
238function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
239 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
240 return {
246}
247
248function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
249 const { id, ...attributes } = raw;
250 return {

lucia_middlewaremain.tsx2 matches

@yawnxyz•Updated 8 months ago
49 interface Register {
50 Lucia: typeof lucia;
51 DatabaseUserAttributes: DatabaseUserAttributes;
52 }
53}
54
55interface DatabaseUserAttributes {
56 github_id: number;
57 username: string;

sqliteExplorerAppREADME.md1 match

@wxw•Updated 8 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

VALLEREADME.md1 match

@gitgrooves•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.

sqliteExplorerAppREADME.md1 match

@jpaulgale•Updated 8 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

lucia_middleware_vanillamain.tsx2 matches

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

lucia_demomain.tsx2 matches

@yawnxyz•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

@yawnxyz•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 {

dobbyREADME.md4 matches

@yawnxyz•Updated 8 months ago
5```javascript
6// Example usage:
7const dobby = new Dobby("myDatabase", [
8 { name: "id", type: "INTEGER", primaryKey: true },
9 { name: "name", type: "TEXT", notNull: true },
12]);
13
14await dobby.createDatabase();
15
16// Insert some sample data
47
48
49// Example of using the new dropDatabase function
50await dropDatabase("myDatabase");
51
52```

sqliteExplorerAppREADME.md1 match

@adamwolf•Updated 8 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