This commit is contained in:
seb
2026-07-31 00:35:02 +02:00
parent a47c598f76
commit fdd9e684d8
10 changed files with 169 additions and 2 deletions

View File

@@ -1,11 +1,21 @@
import sql from 'mssql';
import { CREATE } from '../../sql/company.js';
import { CREATE as CREATE_CATEGORY } from '../../sql/category.js';
export default function create(pool) {
return async ({ name }) => {
const category = await pool
.request()
.input('parentId', sql.Int, null)
.input('sort', sql.Int, 0)
.query(CREATE_CATEGORY);
const rootCategoryId = category.recordset[0].id;
const result = await pool
.request()
.input('name', sql.NVarChar(255), name)
.input('rootCategoryId', sql.Int, rootCategoryId)
.query(CREATE);
return result.recordset[0].id;