
const { transaction, pool } = require('../connection');

async function post(queueId/*unused*/, item_id) {

	const client = await pool.connect();

	const text = `
		UPDATE queue_items
		SET status = 'cancelled'
		WHERE status = 'queued'
			AND (item_id = $1
				OR parent_id = $1);
	`;

	const res = await client.query(text, [item_id]);
	client.release();
	if (!res.rowCount) {
		throw { status: 404, message: "No cancellable requests" };
	}

}

module.exports = post;
