core/orm/collection.py

26 lines
829 B
Python
Raw Normal View History

2023-11-03 10:10:22 +00:00
import time
2023-11-22 16:38:39 +00:00
from sqlalchemy import Column, ForeignKey, Integer, String
2023-10-23 14:51:13 +00:00
from services.db import Base
2022-08-11 09:09:57 +00:00
2022-09-03 10:50:14 +00:00
2022-08-11 09:09:57 +00:00
class ShoutCollection(Base):
2024-01-25 19:41:27 +00:00
__tablename__ = 'shout_collection'
2022-09-03 10:50:14 +00:00
id = None # type: ignore
2024-01-25 19:41:27 +00:00
shout = Column(ForeignKey('shout.id'), primary_key=True)
collection = Column(ForeignKey('collection.id'), primary_key=True)
2022-08-11 09:09:57 +00:00
2022-09-03 10:50:14 +00:00
class Collection(Base):
2024-01-25 19:41:27 +00:00
__tablename__ = 'collection'
2022-09-03 10:50:14 +00:00
2024-02-19 10:25:47 +00:00
slug = Column(String, unique=True, index=True)
2024-01-25 19:41:27 +00:00
title = Column(String, nullable=False, comment='Title')
body = Column(String, nullable=True, comment='Body')
pic = Column(String, nullable=True, comment='Picture')
2023-11-03 10:10:22 +00:00
created_at = Column(Integer, default=lambda: int(time.time()))
2024-01-25 19:41:27 +00:00
created_by = Column(ForeignKey('author.id'), comment='Created By')
published_at = Column(Integer, default=lambda: int(time.time()))