swag-shop/backend/app/models/cart_model.py

17 lines
498 B
Python
Raw Normal View History

from sqlalchemy import ForeignKey, Column, Integer, TIMESTAMP, Float
from sqlalchemy.orm import relationship
from .base_model import Base
class Cart(Base):
__tablename__ = 'cart'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('user.id'), nullable=False)
total = Column(Float, nullable=False)
last_updated = Column(TIMESTAMP)
user = relationship('User', back_populates='carts')
entries = relationship('CartEntry', back_populates='cart')