nestjs_auth init..

This commit is contained in:
최준흠 2022-09-12 12:37:15 +09:00
parent 7ce649bb74
commit 48a6e1d13d
2 changed files with 11 additions and 11 deletions

View File

@ -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<Todo | undefined> {
async fetchOne(@Param('id') id: string): Promise<Todo | undefined> {
return this.todoService.fetchOne({ id: Number(id) })
}
@Post()
add(@Body() data: TodoDTO): Promise<Todo> {
async add(@Body() data: TodoDTO): Promise<Todo> {
return this.todoService.add(data)
}
@Put(':id')
update(@Param('id') id: string, @Body() data: TodoDTO): Promise<Todo> {
async update(@Param('id') id: string, @Body() data: TodoDTO): Promise<Todo> {
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<Todo | undefined> {
async delete(@Param('id') id: string): Promise<Todo | undefined> {
return this.todoService.remove({ id: Number(id) })
}
}

View File

@ -18,7 +18,7 @@ export class TodoService {
where?: Prisma.TodoWhereInput
}): Promise<number> {
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<Todo[]> {
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<Todo | null> {
return this.prisma.todo.findFirstOrThrow({ where: where })
return await this.prisma.todo.findFirstOrThrow({ where: where })
}
//단일 추가
async add(data: Prisma.TodoCreateInput): Promise<Todo> {
return this.prisma.todo.create({ data })
return await this.prisma.todo.create({ data })
}
//단일 수정
@ -58,7 +58,7 @@ export class TodoService {
data: Prisma.TodoUpdateInput
}): Promise<Todo | null> {
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<Todo | null> {
return this.prisma.todo.delete({ where })
return await this.prisma.todo.delete({ where })
}
}