1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 22:44:19 +00:00
pds-2021-g2-nest/code/backend/nest_backend/database/tables/User.py
2021-05-07 19:46:14 +02:00

19 lines
675 B
Python

"""
This module defines the User database class.
"""
from ..base import ext
class User(ext.Model):
__tablename__ = "user"
email = ext.Column(ext.String, primary_key=True)
username = ext.Column(ext.String, nullable=False)
password = ext.Column(ext.LargeBinary, nullable=False)
isAdmin = ext.Column(ext.Boolean, default=False)
# Relationships
owner_of = ext.relationship("Repository", back_populates="owner", cascade="all, delete")
authorizations = ext.relationship("Authorization", back_populates="user", cascade="all, delete")
def to_json(self):
return {'email': self.email, 'username': self.username, 'isAdmin': self.isAdmin}