refactor(server): stack owner (#10900)

This commit is contained in:
Jason Rasmussen
2024-07-05 16:16:53 -04:00
committed by GitHub
parent f6cafa3290
commit e1f25b44d2
14 changed files with 46 additions and 34 deletions

View File

@@ -3,7 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import { StackEntity } from 'src/entities/stack.entity';
import { IStackRepository } from 'src/interfaces/stack.interface';
import { Instrumentation } from 'src/utils/instrumentation';
import { In, Repository } from 'typeorm';
import { Repository } from 'typeorm';
@Instrumentation()
@Injectable()
@@ -34,13 +34,6 @@ export class StackRepository implements IStackRepository {
});
}
async deleteAll(userId: string): Promise<void> {
// TODO add owner to stack entity
const stacks = await this.repository.find({ where: { primaryAsset: { ownerId: userId } } });
const stackIds = new Set(stacks.map((stack) => stack.id));
await this.repository.delete({ id: In([...stackIds]) });
}
private async save(entity: Partial<StackEntity>) {
const { id } = await this.repository.save(entity);
return this.repository.findOneOrFail({