diff --git a/src/todo/todo.controller.ts b/src/todo/todo.controller.ts index aa40ba4..939f041 100644 --- a/src/todo/todo.controller.ts +++ b/src/todo/todo.controller.ts @@ -17,7 +17,7 @@ export class TodoController { constructor(private readonly todoService: TodoService) {} @Get() - fetchAll(@Query() query) { + async fetchAll(@Query() query) { console.log(query) //Field별 filter AND Sql용 @@ -122,17 +122,17 @@ export class TodoController { } @Get(':id') - fetchOne(@Param('id') id: string): Promise { + async fetchOne(@Param('id') id: string): Promise { return this.todoService.fetchOne({ id: Number(id) }) } @Post() - add(@Body() data: TodoDTO): Promise { + async add(@Body() data: TodoDTO): Promise { return this.todoService.add(data) } @Put(':id') - update(@Param('id') id: string, @Body() data: TodoDTO): Promise { + async update(@Param('id') id: string, @Body() data: TodoDTO): Promise { data.updatedAt = new Date() return this.todoService.update({ where: { id: Number(id) }, @@ -141,7 +141,7 @@ export class TodoController { } @Delete(':id') - delete(@Param('id') id: string): Promise { + async delete(@Param('id') id: string): Promise { return this.todoService.remove({ id: Number(id) }) } } diff --git a/src/todo/todo.service.ts b/src/todo/todo.service.ts index 3e4ca3a..105090d 100644 --- a/src/todo/todo.service.ts +++ b/src/todo/todo.service.ts @@ -18,7 +18,7 @@ export class TodoService { where?: Prisma.TodoWhereInput }): Promise { const { cursor, where } = params - return this.prisma.todo.count({ + return await this.prisma.todo.count({ cursor, where }) @@ -33,7 +33,7 @@ export class TodoService { orderBy?: Prisma.TodoOrderByWithRelationInput }): Promise { const { skip, take, cursor, where, orderBy } = params - return this.prisma.todo.findMany({ + return await this.prisma.todo.findMany({ skip, take, cursor, @@ -44,12 +44,12 @@ export class TodoService { //단일 조회 async fetchOne(where: Prisma.TodoWhereInput): Promise { - return this.prisma.todo.findFirstOrThrow({ where: where }) + return await this.prisma.todo.findFirstOrThrow({ where: where }) } //단일 추가 async add(data: Prisma.TodoCreateInput): Promise { - return this.prisma.todo.create({ data }) + return await this.prisma.todo.create({ data }) } //단일 수정 @@ -58,7 +58,7 @@ export class TodoService { data: Prisma.TodoUpdateInput }): Promise { const { where, data } = params - return this.prisma.todo.update({ + return await this.prisma.todo.update({ data, where }) @@ -66,6 +66,6 @@ export class TodoService { //단일 삭제 async remove(where: Prisma.TodoWhereUniqueInput): Promise { - return this.prisma.todo.delete({ where }) + return await this.prisma.todo.delete({ where }) } }