feat: add basic blog features

This commit is contained in:
2026-03-09 22:17:39 +01:00
commit c16657f996
29 changed files with 3095 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import client from "../db/index.js";
export default class PostController {
static async getAll() {
const res = await client.query("SELECT * FROM posts");
return res.rows;
}
static async get(id) {
const res = await client.query({
text: "SELECT * FROM posts WHERE id=$1",
values: [id]
});
return res.rows[0];
}
static async create(title, content) {
const res = await client.query({
text: "INSERT INTO posts(title, content) VALUES($1, $2)",
values: [title, content]
});
console.log(res.rows);
}
}