Add category image add/delete with categorypic SQL layer

This commit is contained in:
seb
2026-08-03 07:38:14 +02:00
parent f8e52549d6
commit 6128fc59fd
6 changed files with 139 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { DELETE_BY_CATEGORY } from '../../sql/categorypic.js';
import resolveCategoryAccess from './resolveCategoryAccess.js';
export default function deleteImage(pool) {
const access = resolveCategoryAccess(pool);
return async (googleAuthId, categoryId) => {
await access(googleAuthId, categoryId);
const result = await pool
.request()
.input('categoryId', categoryId)
.query(DELETE_BY_CATEGORY);
if (!result.rowsAffected[0]) {
throw new Error('Image not found');
}
return {
id: categoryId,
thumbW: null,
thumbH: null,
thumbHash: null,
};
};
}