how do you self join this situation "Categories and subcategories are stored in one…
Jump to turn (8)
- 1how do you self join this situation "Categories and subcategories are stored in
- 2.createQueryBuilder('category') .leftJoinAndSelect('category.parentCategory', 'p
- 3now based on that query add another query to fetch other categories that have th
- 4const categories = new CategoryEntity(); await this.categoryRepository .createQu
- 5async getCategoriesWithSub(): Promise { const categories = await this.categoryRe
- 6return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ U
- 7but i dont have a subCategories column in my entity, wouldnt that matter
- 8show me the updated entity
- User
how do you self join this situation "Categories and subcategories are stored in one table. If a parent category is specified, it is a subcategory" I want to return only categories with an array of their subcategories.
const categories = await this.categoryRepository.createQueryBuilder('category') .leftJoinAndSelect('category.parentCategory', 'parentCategory') .where('parentCategory.id = :parentCategoryId', { parentCategoryId }) .getMany();
- Assistant