MCPcopy Create free account
hub / github.com/codingforentrepreneurs/full-stack-python / BlogPostModel

Class BlogPostModel

full_stack_python/models.py:40–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40class BlogPostModel(rx.Model, table=True):
41 # user
42 # id: int -> primary key
43 userinfo_id: int = Field(default=None, foreign_key="userinfo.id")
44 userinfo: Optional['UserInfo'] = Relationship(back_populates="posts")
45 title: str
46 content: str
47 created_at: datetime = Field(
48 default_factory=utils.timing.get_utc_now,
49 sa_type=sqlalchemy.DateTime(timezone=True),
50 sa_column_kwargs={
51 'server_default': sqlalchemy.func.now()
52 },
53 nullable=False
54 )
55 updated_at: datetime = Field(
56 default_factory=utils.timing.get_utc_now,
57 sa_type=sqlalchemy.DateTime(timezone=True),
58 sa_column_kwargs={
59 'onupdate': sqlalchemy.func.now(),
60 'server_default': sqlalchemy.func.now()
61 },
62 nullable=False
63 )
64 publish_active: bool = False
65 publish_date: datetime = Field(
66 default=None,
67 sa_type=sqlalchemy.DateTime(timezone=True),
68 sa_column_kwargs={},
69 nullable=True
70 )
71
72
73

Callers 1

add_postMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected