add repr to class models and exploring relationships

This commit is contained in:
Yisroel Baum 2024-09-15 15:25:27 +03:00
parent 936a88f264
commit 67264b3da6
11 changed files with 155 additions and 17 deletions

View file

@ -11,5 +11,11 @@ class Donation(db.Model):
id = Column('id', INTEGER(), primary_key=True, autoincrement=True)
currency_type = Column('currency_type', TEXT(), nullable=False)
amount = Column('amount', INTEGER(), nullable=False)
campaign = db.relationship('Campaign', backref='donation', lazy='dynamic')
user = db.relationship('User', backref='donation', lazy='dynamic')
user_id = Column(INTEGER, ForeignKey('user.id'))
campaign_id = Column(INTEGER, ForeignKey('campaign.id'))
def __repr__(self) -> str:
return f"{self.id} - {self.currency_type} - {self.amount}"
# campaign = db.relationship('Campaign', backref='donation', lazy='dynamic')
# user = db.relationship('User', backref='donation', lazy='dynamic')