/
dfr8938
/
store
Обзор
Документация
Войти
/
dfr8938
/
store
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
controllers/post.controller.js
30 строк
589 B
dfr8938
first_commit
22 ноя 2025, 22:40
22 ноя 2025, 22:40
68c763a
Код
Авторство
О чём код?
const db = require("./../db.js"); class PostController { async create(req, res) { const { title, content, userId } = req.body; const post = await db .query(`INSERT INTO posts (title, content, user_id) VALUES ($1, $2, $3) RETURNING *`, [title, content, userId]); res.json(post.rows[0]); }; async getAll(req, res) { const posts = await db.query(`SELECT * FROM posts`); }; async getOne(req, res) { }; async update(req, res) { }; async delete(req, res) { }; } module.exports = new PostController();