Constructable
ConstructableFromORM(id, created_at, updated_at, *, _orm_check=False)
Bases: ABC
Abstract base class for models that can be constructed from ORM models. It serves as a base class for any class that relates directly to an ORM model.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
The unique identifier for the model. |
created_at |
datetime
|
The timestamp when the object was created. |
updated_at |
datetime
|
The timestamp when the object was last updated. |
Source code in svs_core/db/constructable.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
from_orm(model, **kwargs)
abstractmethod
staticmethod
Create an instance of the class from an ORM model. Args: model (object): The ORM model instance to construct from. **kwargs: Additional keyword arguments for customization. Returns: ConstructableFromORM: An instance of the class constructed from the ORM model.
Source code in svs_core/db/constructable.py
35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
from_orm_generic(model, **kwargs)
classmethod
Create an instance of the class from an ORM model using a generic type. Args: cls (Type[T]): The class type to construct. model (object): The ORM model instance to construct from. **kwargs: Additional keyword arguments for customization. Returns: T: An instance of the class constructed from the ORM model.
Source code in svs_core/db/constructable.py
49 50 51 52 53 54 55 56 57 58 59 60 61 |
|