Issue
And still managing to do @OneToMany in another entity.
export class ProductsOfOrder { 
    @ManyToOne(() => Order, order => order.products)
    order: Order
    @ManyToOne(() => Product)
    product: Product
    @Column({type: 'integer'})
    amount: number
}
In the case using the foreign key of order
@Entity()
export class Order {
    @PrimaryGeneratedColumn('uuid')
    id: string
    @ManyToOne(() => User)
    user: User
    @OneToMany(() => ProductsOfOrder, productsOfOrder => productsOfOrder.order, {cascade: true})
    products: ProductsOfOrder[]
}
Solution
Ciao, no you can't because its required for entities to have a primary column in terms of ORM because most of ORM operations are heavily rely on entity primary ids.
Answered By - Giovanni Esposito
 
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.