28 lines
893 B
Python
28 lines
893 B
Python
#db/models/Path.py
|
|
from sqlalchemy import Column, String, Integer, ForeignKey, UniqueConstraint
|
|
from db.models import Base
|
|
|
|
|
|
class Path(Base):
|
|
__tablename__ = "path"
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(50), nullable=False)
|
|
parent_id = Column(Integer, ForeignKey("path.id"), nullable=True)
|
|
__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,
|
|
}
|
|
|
|
__pay_load__ = {
|
|
'dev': [
|
|
{'id': 1, 'name': '', 'parent_id': None},
|
|
{'id': 2, 'name': 'test', 'parent_id': 1},
|
|
{'id': 3, 'name': 'test1', 'parent_id': 1},
|
|
],
|
|
'prod': [
|
|
{'id': 1, 'name': '', 'parent_id': None},
|
|
]
|
|
} |