Module userland.models.oneliner
Oneliner model
Classes
class Oneliner (**data)
-
Expand source code
class Oneliner(SQLModel, table=True): """Oneliner model""" MAX_LENGTH: ClassVar = 120 """Maximum length of oneliner messages""" id: int | None = Field(primary_key=True, default=None) """Unique ID""" user_id: int | None = Field(foreign_key="user.id", default=None) """User ID of the author""" user: User | None = Relationship() """Author of the oneliner""" message: str = Field(max_length=MAX_LENGTH) """The oneliner message""" timestamp: datetime = Field(default_factory=datetime.now) """When the oneliner was posted""" def __init__(self, **data: Any): super().__init__(**data) def __repr__(self): # pragma: no cover return f"Oneliner(#{self.id})"
Oneliner model
Ancestors
- sqlmodel.main.SQLModel
- pydantic.main.BaseModel
Class variables
var MAX_LENGTH : ClassVar
-
Maximum length of oneliner messages
var model_config
Instance variables
var id : int | None
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Unique ID
var message : str
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
The oneliner message
var timestamp : datetime.datetime
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
When the oneliner was posted
var user : sqlalchemy.orm.base.Mapped[User | None]
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
Author of the oneliner
var user_id : int | None
-
Expand source code
def __get__( self, instance: Optional[object], owner: Any ) -> Union[InstrumentedAttribute[_T_co], _T_co]: if instance is None: return self dict_ = instance_dict(instance) if self.impl.supports_population and self.key in dict_: return dict_[self.key] # type: ignore[no-any-return] else: try: state = instance_state(instance) except AttributeError as err: raise orm_exc.UnmappedInstanceError(instance) from err return self.impl.get(state, dict_) # type: ignore[no-any-return]
User ID of the author