Class that represents a shorturl of our application The following attributes of a shorturl are stored in this table: * original_url - url who user give us * short_id - short_id that serves to redirect to the original_url * created_at - creation date
| 3 | |
| 4 | |
| 5 | class ShortUrl(db.Model): |
| 6 | """ |
| 7 | Class that represents a shorturl of our application |
| 8 | The following attributes of a shorturl are stored in this table: |
| 9 | * original_url - url who user give us |
| 10 | * short_id - short_id that serves to redirect to the original_url |
| 11 | * created_at - creation date |
| 12 | """ |
| 13 | id = db.Column(db.Integer, primary_key=True) |
| 14 | original_url = db.Column(db.String(500), nullable=False) |
| 15 | short_id = db.Column(db.String(20), nullable=False, unique=True) |
| 16 | created_at = db.Column(db.DateTime(), default=datetime.now(), nullable=False) |
| 17 | |
| 18 | def __repr__(self): |
| 19 | return f'ShortUrl: {self.short_id}' |
no outgoing calls