// src/entities/cart.entity.ts
import { Entity, PrimaryGeneratedColumn, OneToOne, OneToMany, JoinColumn } from 'typeorm';
import { User } from '../entity/Users';
import { CartItem } from '../entity/cart-item';

@Entity()
export class Cart {
  @PrimaryGeneratedColumn()
  cart_id?: number;

  // Relations
  @OneToOne(() => User, user => user.cart)
  @JoinColumn({ name: 'user_id' })
  user?: User;

  @OneToMany(() => CartItem, cartItem => cartItem.cart)
  items?: CartItem[];
}