MCPcopy Create free account
hub / github.com/outerbase/studio / ValtownQueryable

Class ValtownQueryable

src/drivers/database/valtown.ts:5–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import { transformRawResult } from "./turso";
4
5export class ValtownQueryable implements QueryableBaseDriver {
6 constructor(protected token: string) {}
7
8 async transaction(stmts: InStatement[]): Promise<DatabaseResultSet[]> {
9 const r = await fetch(`https://api.val.town/v1/sqlite/batch`, {
10 method: "POST",
11 headers: {
12 Authorization: "Bearer " + this.token,
13 "Content-Type": "application/json",
14 },
15 body: JSON.stringify({
16 statements: stmts,
17 mode: "write",
18 }),
19 });
20
21 const json = await r.json();
22 return json.map(transformRawResult);
23 }
24
25 async query(stmt: InStatement): Promise<DatabaseResultSet> {
26 const r = await fetch(`https://api.val.town/v1/sqlite/execute`, {
27 method: "POST",
28 headers: {
29 Authorization: "Bearer " + this.token,
30 "Content-Type": "application/json",
31 },
32 body: JSON.stringify({ statement: stmt }),
33 });
34
35 const json = await r.json();
36
37 return transformRawResult(json as ResultSet);
38 }
39}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected