This commit is contained in:
seb
2026-07-06 01:31:11 +02:00
commit 917930d0fa
34 changed files with 2912 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import sql from 'mssql';
export const CATEGORY_TREE_CTE = `
WITH CategoryTree AS (
SELECT kKategorie FROM dbo.tKategorie WHERE kKategorie = @rootCategoryId
UNION ALL
SELECT t.kKategorie
FROM dbo.tKategorie t
INNER JOIN CategoryTree ct ON t.kOberKategorie = ct.kKategorie
)`;
export function getRootCategoryId() {
return Number(process.env.ROOT_CATEGORY_ID) || 1;
}
export function categoryTreeRequest(pool, rootCategoryId = getRootCategoryId()) {
return pool.request().input('rootCategoryId', sql.Int, rootCategoryId);
}