初始版本
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
博客文章模型
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from sqlmodel import SQLModel, Field, Relationship
|
||||
from .user import User
|
||||
|
||||
|
||||
class Post(SQLModel, table=True):
|
||||
"""博客文章表"""
|
||||
__tablename__ = "posts"
|
||||
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
title: str = Field(max_length=200)
|
||||
slug: str = Field(max_length=200, index=True)
|
||||
content: str # 支持 Markdown
|
||||
created_at: datetime = Field(default_factory=datetime.now)
|
||||
updated_at: Optional[datetime] = Field(default=None)
|
||||
user_id: int = Field(foreign_key="users.id", index=True)
|
||||
|
||||
# 关系
|
||||
user: Optional[User] = Relationship()
|
||||
|
||||
Reference in New Issue
Block a user