Genesis
This commit is contained in:
18
src/queries/category-tree.js
Normal file
18
src/queries/category-tree.js
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user