I have three models that have chaining foreign-keys. I'd like to create a relationship between the first model and the last model using those intermediary foreign-keys as joins.
The code looks something like the below:
class A(Model):
# Hypothetical relationship I'd like to have.
c_relationship = relationship('C', backref='A')
class B(Model):
a_id = db.Column(db.Integer, db.ForeignKey('a.id'))
class C(Model):
# C is indirectly related to A through B.
b_id = db.Column(db.Integer, db.ForeignKey('b.id'))