Skip to content

Wiki

Cascades

Official docs

class User(Base):
    # ...

    addresses = relationship("Address", cascade="all, delete-orphan")

When, a User object is marked for completion, addresses associated with the object will also be deleted. Same goes for addresses that have been de-associated from their parent.

Query on JSON field

query = Table.query.filter(Table.json_column.contains({"someField": True}))

Single table inheritance alongside mixins

A mixin that sets table name for a table can be used for a single table inheritance scenario by just setting __tablename__ to None in subclasses.

More here.