1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 23:14:19 +00:00
pds-2021-g2-nest/nest_backend/database/tables/User.py

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}