Add category image add/delete with categorypic SQL layer
This commit is contained in:
26
src/store/category/deleteImage.js
Normal file
26
src/store/category/deleteImage.js
Normal 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,
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user