u
This commit is contained in:
20
src/store/article/deleteImage.js
Normal file
20
src/store/article/deleteImage.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { DELETE_BY_ARTICLE_AND_HASH } from '../../sql/pic.js';
|
||||
import resolveArticleBySku from './resolveArticleBySku.js';
|
||||
|
||||
export default function deleteImage(pool) {
|
||||
const resolve = resolveArticleBySku(pool);
|
||||
|
||||
return async (googleAuthId, sku, fullHash) => {
|
||||
const { articleId } = await resolve(googleAuthId, sku);
|
||||
|
||||
const result = await pool
|
||||
.request()
|
||||
.input('articleId', articleId)
|
||||
.input('fullHash', fullHash)
|
||||
.query(DELETE_BY_ARTICLE_AND_HASH);
|
||||
|
||||
if (!result.rowsAffected[0]) {
|
||||
throw new Error('Image not found');
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user