// 書き込み import "https://deno.land/
[email protected]/dotenv/load.ts"; import { serve } from "https://deno.land/
[email protected]/http/server.ts"; import { type Config, createClient } from "https://esm.sh/@libsql/client"; const config = { url: Deno.env.get("TURSO_DB_URL"), authToken: Deno.env.get("TURSO_AUTH_TOKEN"), } as Config; const db = createClient(config); await serve( async (request) => { console.time("insert"); for await (const i of Array(100).keys()) { await db.execute({ sql: "INSERT INTO items(name) VALUES(?)", args: [`USER${i}`], }); } console.timeEnd("insert"); return new Response(JSON.stringify({ items: [1, 2, 3] }), { headers: { "content-type": "application/json" }, }); }, { port: 8000 } ); // 読み込み import "https://deno.land/
[email protected]/dotenv/load.ts"; import { serve } from "https://deno.land/
[email protected]/http/server.ts"; import { type Config, createClient } from "https://esm.sh/@libsql/client"; const config = { url: Deno.env.get("TURSO_DB_URL"), authToken: Deno.env.get("TURSO_AUTH_TOKEN"), } as Config; const db = createClient(config); await serve( async (request) => { console.time("select"); for await (const _ of Array(100).keys()) { await db.execute("SELECT * FROM items"); } console.timeEnd("select"); return new Response(JSON.stringify({ items: [1, 2, 3] }), { headers: { "content-type": "application/json" }, }); }, { port: 8000 } );