import { pool } from '../pool.js'; export async function create({ transcript = '', duration_ms = null, bytes = null, mime = null, path }) { const { rows } = await pool.query( `INSERT INTO voice_clips (transcript, duration_ms, bytes, mime, path) VALUES ($1,$2,$3,$4,$5) RETURNING *`, [transcript, duration_ms, bytes, mime, path]); return rows[0]; } export async function list(limit = 100) { const { rows } = await pool.query( `SELECT id, transcript, duration_ms, bytes, mime, created_at FROM voice_clips ORDER BY created_at DESC LIMIT $1`, [limit]); return rows; } export async function get(id) { const { rows } = await pool.query(`SELECT * FROM voice_clips WHERE id = $1`, [id]); return rows[0] || null; } export async function remove(id) { const { rows } = await pool.query(`DELETE FROM voice_clips WHERE id = $1 RETURNING path`, [id]); return rows[0] || null; // returns {path} so the caller can unlink the file }