Hello, Taking the relationship examples from the documentation <https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html>, suppose I have the following:
class Parent(Base): __tablename__ = "parent" id = Column(Integer, primary_key=True) oldest_child_id = Column(Integer, ForeignKey("child.id")) oldest_child = relationship("Child", foreign_keys=oldest_child_id) youngest_child_id = Column(Integer, ForeignKey("child.id")) youngest_child = relationship("Child", foreign_keys=oldest_child_id) # children = ... class Child(Base): __tablename__ = "child" id = Column(Integer, primary_key=True) For the sake of argument, we care for exactly two children per parent. Now my question is: how can I introduce a set/list of all children on the parent? The naive approach would be something like @property def children(self): return [self.oldest_child, self.youngest_child] # Or set(), or tuple(). In my particular case, the Child is actually a File table, and different other tables may have one or more Files associated. But it would be nice if these tables had a “files” property which is a consolidation of all their explicitly associated files. Thank you! Jens -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/b13c7494-ab23-44ba-a878-19fd7c0d1f63%40googlegroups.com.