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=284&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 2901 results for "database"(593ms)

sqliteREADME.md2 matches

@maxm•Updated 8 months ago
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)

sqlitemain.tsx1 match

@maxm•Updated 8 months ago
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))

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 {

VALLEREADME.md1 match

@tmcw•Updated 9 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.

valleGetValsContextWindowmain.tsx1 match

@stevekrouse•Updated 9 months ago
105 {
106 name: "Use Val Town SQLite to store data",
107 prompt: "Write a val that uses an SQLite database",
108 code: `import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
109

infiniteSVGGraphmain.tsx1 match

@maxm•Updated 9 months ago
33// }
34
35// Database querying.
36
37function parseResultSet<T>(row: ResultSet): T[] {

dateme_react_hydratedREADME.md2 matches

@stevekrouse•Updated 10 months ago
9## Contributing
10
11Forking this repo should mostly work, except for the sqlite database. You'll need to create the table & populate it with some data. [This script](https://www.val.town/v/stevekrouse/dateme_sqlite) *should* do it, but I think it has a couple bugs. If you're interested in contributing to this project contact me or comment on this val and I'll get it working for ya!
12
13## Todos
14
15- [ ] Make the SQLite database forkable and build a widget/workflow for that, ie fix @stevekrouse/dateme_sqlite
16- [ ] Require an email (that isn't shared publicly)
17 - [ ] Verify the email address with a "magic link"

dateme_react_clientREADME.md2 matches

@stevekrouse•Updated 10 months ago
9## Contributing
10
11Forking this repo should mostly work, except for the sqlite database. You'll need to create the table & populate it with some data. [This script](https://www.val.town/v/stevekrouse/dateme_sqlite) *should* do it, but I think it has a couple bugs. If you're interested in contributing to this project contact me or comment on this val and I'll get it working for ya!
12
13## Todos
14
15- [ ] Make the SQLite database forkable and build a widget/workflow for that, ie fix @stevekrouse/dateme_sqlite
16- [ ] Require an email (that isn't shared publicly)
17 - [ ] Verify the email address with a "magic link"

amaranthTakinREADME.md2 matches

@stevekrouse•Updated 12 months ago
9## Contributing
10
11Forking this repo should mostly work, except for the sqlite database. You'll need to create the table & populate it with some data. [This script](https://www.val.town/v/stevekrouse/dateme_sqlite) *should* do it, but I think it has a couple bugs. If you're interested in contributing to this project contact me or comment on this val and I'll get it working for ya!
12
13## Todos
14
15- [ ] Make the SQLite database forkable and build a widget/workflow for that, ie fix @stevekrouse/dateme_sqlite
16- [ ] Require an email (that isn't shared publicly)
17 - [ ] Verify the email address with a "magic link"

yc_database

@stevekrouse•Updated 5 months ago

dateMeNotionDatabase2 file matches

@stevekrouse•Updated 1 year ago