This commit is contained in:
seb
2026-07-31 09:09:34 +02:00
parent 84a7c6f7ef
commit 818d799f63
6 changed files with 21 additions and 38 deletions

View File

@@ -1,7 +1,16 @@
import { DELETE } from '../../sql/category.js';
import resolveCategoryAccess from './resolveCategoryAccess.js';
export default function del(pool) {
return async (id) => {
const access = resolveCategoryAccess(pool);
return async ({ googleAuthId, id }) => {
const { rootCategoryId } = await access(googleAuthId, id);
if (id === rootCategoryId) {
throw new Error('Cannot delete root category');
}
await pool.request().input('id', id).query(DELETE);
};
}

View File

@@ -1,11 +0,0 @@
import { UPDATE_PARENT_ID } from '../../sql/category.js';
export default function updateParentId(pool) {
return async (id, parentId) => {
await pool
.request()
.input('id', id)
.input('parentId', parentId)
.query(UPDATE_PARENT_ID);
};
}