add: order paths & mds
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#db/models/Markdown.py
|
||||
from sqlalchemy import Column, Text, Integer, String, DateTime, ForeignKey
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import Column, Text, Integer, String, DateTime, ForeignKey, Float, text
|
||||
from db.models import Base
|
||||
import datetime
|
||||
|
||||
@@ -10,6 +11,7 @@ class Markdown(Base):
|
||||
content = Column(Text, nullable=False)
|
||||
created_at = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
path_id = Column(Integer, ForeignKey('path.id'), nullable=False)
|
||||
order = Column(String(36), default=lambda: str(uuid.uuid4()))
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -18,6 +20,7 @@ class Markdown(Base):
|
||||
'content': self.content,
|
||||
'created_at': self.created_at,
|
||||
'path_id': self.path_id,
|
||||
'order': self.order,
|
||||
}
|
||||
__pay_load__ = {
|
||||
'dev': [
|
||||
@@ -26,4 +29,4 @@ class Markdown(Base):
|
||||
'prod': [
|
||||
{'id': 1, 'title': 'index', 'content': ' ', 'created_at': datetime.datetime.utcnow, 'path_id': 1},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#db/models/Path.py
|
||||
from sqlalchemy import Column, String, Integer, ForeignKey, UniqueConstraint
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import Column, String, Integer, ForeignKey, UniqueConstraint, text
|
||||
from db.models import Base
|
||||
|
||||
|
||||
@@ -8,12 +9,14 @@ class Path(Base):
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(50), nullable=False)
|
||||
parent_id = Column(Integer, ForeignKey("path.id"), nullable=True)
|
||||
order = Column(String(36), default=lambda: str(uuid.uuid4()))
|
||||
__table_args__ = (UniqueConstraint("parent_id", "name", name="unique_parent_id_name"), )
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"parent_id": self.parent_id,
|
||||
"order": self.order,
|
||||
}
|
||||
|
||||
__pay_load__ = {
|
||||
@@ -25,4 +28,6 @@ class Path(Base):
|
||||
'prod': [
|
||||
{'id': 1, 'name': '', 'parent_id': None},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user