34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import uuid
|
|
|
|
from sqlalchemy import Column, Text, Integer, String, DateTime, ForeignKey, Float, text, UniqueConstraint
|
|
from db.models import Base
|
|
import datetime
|
|
|
|
class Markdown(Base):
|
|
__tablename__ = 'markdown'
|
|
id = Column(Integer, primary_key=True)
|
|
title = Column(String(255), nullable=False)
|
|
content = Column(Text, nullable=False)
|
|
created_at = Column(DateTime, default=datetime.datetime.now(datetime.UTC))
|
|
path_id = Column(Integer, ForeignKey('path.id'), nullable=False)
|
|
order = Column(String(36), default=lambda: str(uuid.uuid4()))
|
|
shortcut = Column(String(36), default="")
|
|
def to_dict(self):
|
|
return {
|
|
'id': self.id,
|
|
'title': self.title,
|
|
'content': self.content,
|
|
'created_at': self.created_at,
|
|
'path_id': self.path_id,
|
|
'order': self.order,
|
|
'shortcut': self.shortcut,
|
|
}
|
|
__payload__ = {
|
|
'dev': [
|
|
{'id': 1, 'title': 'index', 'content': ' ', 'created_at': datetime.datetime.utcnow, 'path_id': 1 },
|
|
],
|
|
'prod': [
|
|
{'id': 1, 'title': 'index', 'content': ' ', 'created_at': datetime.datetime.utcnow, 'path_id': 1},
|
|
]
|
|
}
|