2023-10-11 04:14:44 +02:00
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
2024-03-20 15:04:03 -05:00
|
|
|
import { DummyValue, GenerateSql } from 'src/decorators';
|
2024-03-20 16:02:51 -05:00
|
|
|
import { MoveEntity, PathType } from 'src/entities/move.entity';
|
2024-03-21 12:59:49 +01:00
|
|
|
import { IMoveRepository, MoveCreate } from 'src/interfaces/move.interface';
|
2024-03-20 22:15:09 -05:00
|
|
|
import { Instrumentation } from 'src/utils/instrumentation';
|
2023-10-11 04:14:44 +02:00
|
|
|
import { Repository } from 'typeorm';
|
|
|
|
|
2024-03-12 01:19:12 -04:00
|
|
|
@Instrumentation()
|
2023-10-11 04:14:44 +02:00
|
|
|
@Injectable()
|
|
|
|
export class MoveRepository implements IMoveRepository {
|
|
|
|
constructor(@InjectRepository(MoveEntity) private repository: Repository<MoveEntity>) {}
|
|
|
|
|
|
|
|
create(entity: MoveCreate): Promise<MoveEntity> {
|
|
|
|
return this.repository.save(entity);
|
|
|
|
}
|
|
|
|
|
2023-11-30 10:10:30 -05:00
|
|
|
@GenerateSql({ params: [DummyValue.UUID, DummyValue.STRING] })
|
2023-10-11 04:14:44 +02:00
|
|
|
getByEntity(entityId: string, pathType: PathType): Promise<MoveEntity | null> {
|
|
|
|
return this.repository.findOne({ where: { entityId, pathType } });
|
|
|
|
}
|
|
|
|
|
|
|
|
update(entity: Partial<MoveEntity>): Promise<MoveEntity> {
|
|
|
|
return this.repository.save(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(move: MoveEntity): Promise<MoveEntity> {
|
|
|
|
return this.repository.remove(move);
|
|
|
|
}
|
|
|
|
}
|