Skip to content

Instantly share code, notes, and snippets.

@jasonwalkeryung
Last active December 5, 2017 20:35
Show Gist options
  • Save jasonwalkeryung/f6c45b314381b5e90dab63c8d3469258 to your computer and use it in GitHub Desktop.
Save jasonwalkeryung/f6c45b314381b5e90dab63c8d3469258 to your computer and use it in GitHub Desktop.
Eager loading
class Product(ExampleModel):
name = Column(String, nullable=False)
description = Column(Text)
list_price = Column(Numeric)
sell_price = Column(Numeric)
variants = relationship('Variant', backref="product")
class Variant(ExampleModel):
product_id = Column(ForeignKey('products.id'))
inventory = relationship('Inventory')
class Inventory(ExampleModel):
variant_id = Column(ForeignKey('variants.id'))
available_to_sell = Column(Integer, nullable=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment