-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
22 lines (18 loc) · 810 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from extensions import db
from sqlalchemy.orm import relationship
from flask_login import UserMixin
class User(UserMixin, db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
email = db.Column(db.String, nullable=False)
password = db.Column(db.String, nullable=False)
playlists = relationship('Playlist', back_populates='user')
class Playlist(db.Model):
__tablename__ = 'playlists'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
user = relationship("User", back_populates='playlists')
original_date = db.Column(db.String, nullable=False)
date = db.Column(db.String, nullable=False)
link = db.Column(db.String, nullable=False)