remove listings from listingstable when clicked

This commit is contained in:
orangecoding
2025-10-03 13:27:44 +02:00
parent f97fb48e51
commit 3aa30bc1e2
5 changed files with 69 additions and 7 deletions

View File

@@ -258,7 +258,19 @@ export const queryListings = ({
* @param {string} jobId - The job identifier whose listings should be removed.
* @returns {any} The result from SqliteConnection.execute (may contain changes count).
*/
export const deleteListings = (jobId) => {
export const deleteListingsByJobId = (jobId) => {
if (!jobId) return;
return SqliteConnection.execute(`DELETE FROM listings WHERE job_id = @jobId`, { jobId });
};
/**
* Delete listings by a list of listing IDs.
*
* @param {string[]} ids - Array of listing IDs to delete.
* @returns {any} The result from SqliteConnection.execute.
*/
export const deleteListingsById = (ids) => {
if (!Array.isArray(ids) || ids.length === 0) return;
const placeholders = ids.map(() => '?').join(',');
return SqliteConnection.execute(`DELETE FROM listings WHERE id IN (${placeholders})`, ids);
};