typeorm simplified

Hussain Wali
Jul 2, 2021

--

// cascade:[‘insert’] on one CONTRACT to many CONTRACTROUTES

means if I insert a CONTRACT LOOK FOR CONTRACTROUTES WITHIN import PropTypes from ‘prop-types’

// if there are CONTRACTROUTES within

@OneToMany(() => ContractRouteEntity, (contract_route) => contract_route.contract, { cascade: [‘insert’], nullable: true, eager: true })

contract_routes: ContractRouteEntity[];

Circular Dependency Fix

The error:

screenshot of the error
(node:16680) UnhandledPromiseRejectionWarning: Error: A circular dependency has been detected (property key: "vehicle_type"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").

Fix:

this is required

@ApiProperty({type:()=>VehicleTypeEntity})

@ApiProperty({ type: () => VehicleTypeEntity })
@ManyToOne(() => VehicleTypeEntity, vehicletype => vehicletype.contract_route_vehicles, { eager: true })
@JoinColumn({ name: 'vehicletype_id', referencedColumnName: 'vehicletype_id' })
vehicle_type: VehicleTypeEntity

--

--

Hussain Wali

Software Engineer by profession. Data Scientist by heart. MS Data Science at National University of Science and Technology Islamabad.