Forked from samwillis/PGliteOld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import "https://deno.land/x/xhr@0.1.0/mod.ts";
import { PGlite } from "https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/index.js";
const pg = new PGlite();
let init = (async () => {
await pg.query(`
CREATE TABLE IF NOT EXISTS test (
id SERIAL PRIMARY KEY,
test TEXT
);
`);
await pg.query(`
INSERT INTO test (test)
SELECT 'valtown ' || id
FROM GENERATE_SERIES(1, 10) AS id;
`);
})();
export default async function(req: Request): Promise<Response> {
await init;
return Response.json([
await pg.query("SELECT version()"),
await pg.query("SELECT now()"),
await pg.query("SELECT * FROM test"),
]);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 1, 2024