|
@@ -130,7 +130,7 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
|
return items.sort((itemA, itemB) => itemB.updated_at_timestamp - itemA.updated_at_timestamp)
|
|
return items.sort((itemA, itemB) => itemB.updated_at_timestamp - itemA.updated_at_timestamp)
|
|
}
|
|
}
|
|
|
|
|
|
- async findByUuidAndUserUuid(uuid: string, userUuid: string): Promise<Item | null> {
|
|
|
|
|
|
+ async findByUuidAndUserUuid(uuid: string, userUuid: string, noAssociations: boolean): Promise<Item | null> {
|
|
const persistence = await this.ormRepository
|
|
const persistence = await this.ormRepository
|
|
.createQueryBuilder('item')
|
|
.createQueryBuilder('item')
|
|
.where('item.uuid = :uuid AND item.user_uuid = :userUuid', {
|
|
.where('item.uuid = :uuid AND item.user_uuid = :userUuid', {
|
|
@@ -146,6 +146,10 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
|
try {
|
|
try {
|
|
const item = this.mapper.toDomain(persistence)
|
|
const item = this.mapper.toDomain(persistence)
|
|
|
|
|
|
|
|
+ if (noAssociations) {
|
|
|
|
+ return item
|
|
|
|
+ }
|
|
|
|
+
|
|
await this.decorateItemWithAssociations(item)
|
|
await this.decorateItemWithAssociations(item)
|
|
|
|
|
|
return item
|
|
return item
|
|
@@ -156,7 +160,7 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- async findAll(query: ItemQuery): Promise<Item[]> {
|
|
|
|
|
|
+ async findAll(query: ItemQuery, noAssociations: boolean): Promise<Item[]> {
|
|
const persistence = await this.createFindAllQueryBuilder(query).getMany()
|
|
const persistence = await this.createFindAllQueryBuilder(query).getMany()
|
|
|
|
|
|
const domainItems: Item[] = []
|
|
const domainItems: Item[] = []
|
|
@@ -168,6 +172,10 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (noAssociations) {
|
|
|
|
+ return domainItems
|
|
|
|
+ }
|
|
|
|
+
|
|
await Promise.all(domainItems.map((item) => this.decorateItemWithAssociations(item)))
|
|
await Promise.all(domainItems.map((item) => this.decorateItemWithAssociations(item)))
|
|
|
|
|
|
return domainItems
|
|
return domainItems
|