From 914f6861008497b8fde09f743b5cfb07f0e905e5 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Sat, 11 May 2024 14:52:20 +0700 Subject: [PATCH] Create file.py --- app/models/file.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/models/file.py diff --git a/app/models/file.py b/app/models/file.py new file mode 100644 index 0000000..6687928 --- /dev/null +++ b/app/models/file.py @@ -0,0 +1,19 @@ +# File model +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import relationship + +Base = declarative_base() + +class File(Base): + __tablename__ = 'files' + id = Column(Integer, primary_key=True) + name = Column(String) + content = Column(String) + user_id = Column(Integer, ForeignKey('users.id')) + user = relationship('User', backref='files') + + def __init__(self, name, content, user): + self.name = name + self.content = content + self.user = user