nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using DTO to execute query but facing Types of property 'shop_id' are incompatible.

austinp0wers opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I am trying to save the order information by using a dto,
however in my repository file i keep getting an error saying

Overload 1 of 4, '(entities: DeepPartial<ReservationEntity>[], options?: SaveOptions): Promise<(DeepPartial<ReservationEntity> & ReservationEntity)[]>', gave the following error.
    Argument of type '{ user_id: string; reserve_date: Date; shop_id: string; }' is not assignable to parameter of type 'DeepPartial<ReservationEntity>[]'.
      Type '{ user_id: string; reserve_date: Date; shop_id: string; }' is missing the following properties from type 'DeepPartial<ReservationEntity>[]': length, pop, push, concat, and 29 more.

this is my DTO.

export interface saveOrderInformationDto {
  user_id: string;
  reserve_date: Date;
  shop_id: string;
}

and here's where it's implemented.

reservation.repository.ts

  async saveReservation(orderInfoDto: saveOrderInformationDto) {

    this.reservationRepo.save(orderInfoDto);
  }

I've used, save, insert but both spitting out same error.
Not sure how to deal with the issue.

is there a way to just use plain SQL query to solve this problem?

Minimum reproduction code

https://github.com/austinp0wers/typeorm-Issue/blob/main/README.md

Steps to reproduce

No response

Expected behavior

i was expecting the order information to be saved in my db.

Package version

8.0.1

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Please use our Discord. This is not a bug, nor a feature request and isn't related to NestJS itself but TypeScript & TypeORM.

Also, you didn't shared enough information to help you out. I could help you at discord (#typeorm channel)