1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/wikipack/tables/wikipage.py

24 lines
654 B
Python
Raw Normal View History

2020-06-22 01:58:55 +00:00
from typing import *
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declared_attr
if TYPE_CHECKING:
from .wikirevision import WikiRevision
class WikiPage:
__tablename__ = "wikipages"
@declared_attr
def page_id(self) -> int:
return Column(Integer, primary_key=True)
@declared_attr
def latest_revision_id(self) -> int:
return Column(Integer, ForeignKey("wikirevisions.revision_id"), nullable=False)
@declared_attr
def latest_revision(self) -> "WikiRevision":
return relationship("WikiRevision", foreign_keys=self.latest_revision_id, uselist=False)