chore: migrate database files (#8126)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { DummyValue, GenerateSql } from 'src/decorators';
|
||||
import { MoveEntity, PathType } from 'src/entities/move.entity';
|
||||
import { Instrumentation } from 'src/infra/instrumentation';
|
||||
import { IMoveRepository, MoveCreate } from 'src/interfaces/move.repository';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Instrumentation()
|
||||
@Injectable()
|
||||
export class MoveRepository implements IMoveRepository {
|
||||
constructor(@InjectRepository(MoveEntity) private repository: Repository<MoveEntity>) {}
|
||||
|
||||
create(entity: MoveCreate): Promise<MoveEntity> {
|
||||
return this.repository.save(entity);
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [DummyValue.UUID, DummyValue.STRING] })
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user