This commit is contained in:
danis
2023-01-04 18:10:19 +03:00
parent bdf7cad952
commit f65d0fb096
2 changed files with 11 additions and 19 deletions
+3 -8
View File
@@ -16,11 +16,6 @@ export class SearchController {
return this.searchService.getHello();
}
// @Get('/all')
// findall(): Promise<Song[] | null> {
// return this.songService.songs();
// }
@Get()
async findAll(
@Req() req: Request,
@@ -46,10 +41,10 @@ export class SearchController {
@Get('/title/:name')
async findByName(@Param('name') name: string): Promise<Song> {
// const ret = await this.searchService.songByTitle({ name })
// if (!ret) throw new NotFoundException();
const ret = await this.searchService.songByTitle({ name })
if (!ret) throw new NotFoundException();
throw new NotFoundException();
// return ret;
return ret;
}
@Get('/advanced')
+8 -11
View File
@@ -5,18 +5,15 @@ import { PrismaService } from 'src/prisma/prisma.service';
@Injectable()
export class SearchService {
constructor(private prisma: PrismaService) {}
// async songByTitle(songWhereUniqueInput: Prisma.SongWhereUniqueInput): Promise<Song | null> {
// // return this.prisma.song.findUnique({
// // where: songWhereUniqueInput,
// // });
// return this.prisma.song.findMany({
// where:
// })
// }
async songByTitle(songWhereUniqueInput: Prisma.SongWhereUniqueInput): Promise<Song | null> {
return this.prisma.song.findUnique({
where: songWhereUniqueInput,
});
}
// async all(): Promise<Song[] | null> {
// return this.prisma.song.findMany
// }
async all(): Promise<Song[] | null> {
return this.prisma.song.findMany
}
getHello(): string {
return 'Hello World!';