diff --git a/api/src/category.repository.ts b/api/src/category.repository.ts index 3afac7b..c0e3437 100644 --- a/api/src/category.repository.ts +++ b/api/src/category.repository.ts @@ -14,14 +14,15 @@ export class CategoryRepository { * Finds all descendants of a given path (including the path itself). * Uses the ltree operator <@ (is-descendant-of). */ - async findAllDescendants(parentPath: string): Promise { + async findAllDescendants(parentPath: string, userId: number): Promise { const query = ` SELECT id, name, path FROM categories WHERE path <@ $1::ltree + AND user_id = $2 -- ORDER BY path ASC; `; - const result = await this.db.query(query, [parentPath]); + const result = await this.db.query(query, [parentPath, userId]); return result.rows; }