u
This commit is contained in:
28
src/store/brand/deleteImage.js
Normal file
28
src/store/brand/deleteImage.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { DELETE_BY_BRAND as MSSQL_DELETE } from '../../providers/mssql/queries/brandpic.js';
|
||||
import { DELETE_BY_BRAND as SQLITE_DELETE } from '../../providers/sqlite3/queries/brandpic.js';
|
||||
import resolveBrandAccess from './resolveBrandAccess.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
export default function deleteImage(provider) {
|
||||
const access = resolveBrandAccess(provider);
|
||||
const sql = provider?.dialect === 'sqlite3' ? SQLITE_DELETE : MSSQL_DELETE;
|
||||
|
||||
return async (googleAuthId, brandId, tx) => {
|
||||
const runner = makeRunner(provider, tx);
|
||||
await access(googleAuthId, brandId, runner);
|
||||
|
||||
const result = await runner.query(sql, { brandId });
|
||||
|
||||
if (!result.rowsAffected) {
|
||||
throw new Error('Image not found');
|
||||
}
|
||||
|
||||
return {
|
||||
id: brandId,
|
||||
thumbW: null,
|
||||
thumbH: null,
|
||||
thumbHash: null,
|
||||
pics: [],
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user