ref: master
core/types/product_category.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from sqlalchemy import Column, Integer, String, DateTime, Text from sqlalchemy.orm import relationship from core.database import Base from datetime import datetime as dt from core.types.product import Product class ProductCategory(Base): __tablename__ = "product_categories" id = Column(Integer, primary_key=True) name = Column(String(255), nullable=False) description = Column(Text) created_at = Column(DateTime, nullable=False) updated_at = Column(DateTime, nullable=False) products = relationship("Product", backref="category", lazy=True) def __init__(self, name, description): self.name = name self.description = description def to_json(self): return { "name": self.name, "description": self.description, } |