From 92993ef105c53858574c696b3d5a20cd54626238 Mon Sep 17 00:00:00 2001 From: Lauren Liberda Date: Tue, 20 Jul 2021 00:34:15 +0200 Subject: [PATCH] fully working item descendants --- src/items/items.model.ts | 2 +- src/items/items.service.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/items/items.model.ts b/src/items/items.model.ts index e837a05..b583259 100644 --- a/src/items/items.model.ts +++ b/src/items/items.model.ts @@ -19,6 +19,6 @@ export class ItemModel { @Field((type) => [ItemModel]) children: ItemModel[]; - @Field((type) => [ItemModel], { deprecationReason: 'typeorm issues' }) + @Field((type) => [ItemModel]) descendents: ItemModel[]; } diff --git a/src/items/items.service.ts b/src/items/items.service.ts index 8a70f95..5d1de00 100644 --- a/src/items/items.service.ts +++ b/src/items/items.service.ts @@ -40,7 +40,8 @@ export class ItemsService { const parentItem = await this.itemRepository.findOneOrFail(item.id, { relations: ['parent'], }); - return this.treeRepository.findDescendants(parentItem); + // TreeRepository.findDescendants()[0] is always the parent item + return (await this.treeRepository.findDescendants(parentItem)).slice(1); } async createItem(input: NewItemInput): Promise {