27 lines
628 B
JavaScript
27 lines
628 B
JavaScript
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,
|
|
};
|
|
};
|
|
}
|