22 lines
963 B
Python
22 lines
963 B
Python
from database import db_connection
|
|
|
|
class Session(db_connection.Model):
|
|
__tablename__ = 'sessions'
|
|
|
|
id = db_connection.Column(db_connection.Integer, primary_key=True)
|
|
user_id = db_connection.Column(db_connection.Integer, db_connection.ForeignKey('users.id'))
|
|
org_id = db_connection.Column(db_connection.Integer, db_connection.ForeignKey('organizations.id'))
|
|
token = db_connection.Column(db_connection.String(255), unique=True)
|
|
created_at = db_connection.Column(db_connection.DateTime, server_default=db_connection.func.now())
|
|
updated_at = db_connection.Column(db_connection.DateTime, server_default=db_connection.func.now(), server_onupdate=db_connection.func.now())
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"id": self.id,
|
|
"user_id": self.user_id,
|
|
"org_id": self.org_id,
|
|
"token": self.token,
|
|
"created_at": self.created_at,
|
|
"updated_at": self.updated_at
|
|
}
|