• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    해결됨

상품 등록 API 오류 납니다

23.12.20 15:49 작성 조회수 145

0

 ERROR [TypeOrmModule] Unable to connect to the database Retrying (2)...
QueryFailedError: Incorrect datetime value: '0000-00-00 00:00:00' for column 'meetingTime' at row 1

라고 오류납니다

 

product.resolver.ts

import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import { ProductsService } from './product.service';
import { CreateBoardInput } from '../boards/dto/create-board.input';
import { CreateProductInput } from './dto/create-product.input';
import { Product } from './entities/product.entity';

@Resolver()
export class ProductsResolver {
    constructor(
        private readonly productsService: ProductsService, //
    ) {}

    @Query(() => [Product])
    fetchProducts(): Promise<Product[]> {
        return this.productsService.findAll();
    }

    @Query(() => Product)
    fetchProduct(
        @Args('productId') productId: string, //
    ): Promise<Product> {
        return this.productsService.findOne({ productId });
    }

    @Mutation(() => Product)
    createProduct(
        @Args('createProductInput') createProductInput: CreateProductInput,
    ): Promise<Product> {
        // << 브라우저에 결과 보내주는 2가지 방법>>

        // 1. 등록된 내용이 담긴 객체를 그대로 브라우저에 보내주기

        return this.productsService.create({ createProductInput });
        // 이걸 선호. 조회 api 요청을 안해도 된다

        // 2.결과에서만 간단히 보내주기
        // return '정상적으로 상품이 등록되었습니다'
    }
}

 

product.service.ts

import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import { ProductsService } from './product.service';
import { CreateBoardInput } from '../boards/dto/create-board.input';
import { CreateProductInput } from './dto/create-product.input';
import { Product } from './entities/product.entity';

@Resolver()
export class ProductsResolver {
    constructor(
        private readonly productsService: ProductsService, //
    ) {}

    @Query(() => [Product])
    fetchProducts(): Promise<Product[]> {
        return this.productsService.findAll();
    }

    @Query(() => Product)
    fetchProduct(
        @Args('productId') productId: string, //
    ): Promise<Product> {
        return this.productsService.findOne({ productId });
    }

    @Mutation(() => Product)
    createProduct(
        @Args('createProductInput') createProductInput: CreateProductInput,
    ): Promise<Product> {
        // << 브라우저에 결과 보내주는 2가지 방법>>

        // 1. 등록된 내용이 담긴 객체를 그대로 브라우저에 보내주기

        return this.productsService.create({ createProductInput });
        // 이걸 선호. 조회 api 요청을 안해도 된다

        // 2.결과에서만 간단히 보내주기
        // return '정상적으로 상품이 등록되었습니다'
    }
}

 

productSaleslocation.entity.ts

import { Field, Float, ObjectType } from '@nestjs/graphql';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
@ObjectType()
export class ProductSaleslocation {
    @PrimaryGeneratedColumn('uuid')
    @Field(() => String)
    id: string;

    @Column()
    @Field(() => String)
    address: string;

    @Column()
    @Field(() => String)
    addressDetail: string;
    //                     // 9자리 중에서 6자리가 소수점
    @Column({ type: 'decimal', precision: 9, scale: 6 })
    @Field(() => Float)
    lat: number;

    @Column({ type: 'decimal', precision: 9, scale: 6 })
    @Field(() => Float)
    lng: number;

    @Column()
    @Field(() => Date)
    meetingTime: Date;
}

 

meetingTime graphlql 타입을 맞게 해났는데 왜 오류나는지 모르곘습니다

 

답변 1

답변을 작성해보세요.

0

안녕하세요! kql1님!

0000년은 입력하실 수 없으세요!

0001-01-01 등의 숫자로 변경하여 입력해 보세요!^^