Public
HTTP (preview)
Forked from maxm/pgliteNpm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { PGlite } from "npm:@electric-sql/pglite";
const db = await PGlite.create();
await db.exec(`
CREATE TABLE IF NOT EXISTS test (
id SERIAL PRIMARY KEY,
test TEXT,
counter INTEGER
);
INSERT INTO test (id, test, counter) VALUES (1, 'valtown', 0);
`);
export default async function(req: Request): Promise<Response> {
const res = await db.query(`
UPDATE test
SET counter = counter + 1
WHERE id = 1
RETURNING counter, test
`);
return Response.json(res.rows[0]);
}
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!
August 29, 2024