|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- # pylint: disable = missing-class-docstring
- # pylint: disable = missing-function-docstring
- # pylint: disable = missing-module-docstring
- # pylint: disable = unused-argument
-
- from __future__ import annotations
-
- from typing import Any, Generic, Type, TypeVar, overload
- from typing_extensions import Self
-
- _ModelT = TypeVar ('_ModelT', bound = 'Model')
-
-
- class Connection:
- def select (self, query: str, bindings: dict[str, Any] | None = None) -> Any: ...
-
- def insert (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
-
- def update (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
-
- def delete (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
-
- def transaction (self, callback: Any) -> Any: ...
-
- def begin_transaction (self) -> None: ...
-
- def commit (self) -> None: ...
-
- def rollback (self) -> None: ...
-
-
- class ConnectionResolver:
- def connection (self, name: str | None = None) -> Any: ...
-
- def get_default_connection (self) -> str: ...
-
- def set_default_connection (self, name: str) -> None: ...
-
-
- class DatabaseManager:
- connections: dict[str, Connection]
-
- def __init__ (self, config: dict[str, Any]) -> None: ...
-
- def connection (self, name: str | None = None) -> Connection: ...
-
- def disconnect (self, name: str | None = None) -> None: ...
-
- def reconnect (self, name: str | None = None) -> Connection: ...
-
- def get_connections (self) -> dict[str, Connection]: ...
-
-
- class Model:
- id: int
-
- _Model__exists: bool
-
- def has_one (
- self,
- related_model: Type[_ModelT],
- foreign_key: str | None = None,
- ) -> _ModelT: ...
-
- def has_many (
- self,
- related_model: Type[_ModelT],
- foreign_key: str | None = None,
- ) -> list[_ModelT]: ...
-
- def belongs_to (
- self,
- related_model: Type[_ModelT],
- foreign_key: str | None = None,
- ) -> _ModelT: ...
-
- def belongs_to_many (
- self,
- related_model: Type[_ModelT],
- foreign_key: str | None = None,
- ) -> list[_ModelT]: ...
-
- def save (self) -> None: ...
-
- def delete (self) -> None: ...
-
- @classmethod
- def find (cls, id_: int) -> Self | None: ...
-
- @classmethod
- def query (
- cls,
- ) -> QueryBuilder[Self]: ...
-
- @overload
- @classmethod
- def where (
- cls,
- field: str,
- operator: str,
- value: Any,
- ) -> QueryBuilder[Self]: ...
-
- @overload
- @classmethod
- def where (cls, field: str, value: Any) -> QueryBuilder[Self]: ...
-
- @classmethod
- def where_not_in (
- cls,
- column: str,
- values: list[Any] | tuple
- ) -> QueryBuilder[Self]: ...
-
- @classmethod
- def where_not_null (cls, field: str) -> QueryBuilder[Self]: ...
-
- @classmethod
- def set_connection_resolver (cls, resolver: DatabaseManager) -> None: ...
-
-
- class QueryBuilder (Generic[_ModelT]):
- def first (self) -> _ModelT | None: ...
-
- def get (self) -> list[_ModelT]: ...
-
- @overload
- def where (
- self,
- field: str,
- operator: str,
- value: Any,
- ) -> QueryBuilder[_ModelT]: ...
-
- @overload
- def where (self, field: str, value: Any) -> QueryBuilder[_ModelT]: ...
-
- def where_null (self, field: str) -> QueryBuilder[_ModelT]: ...
-
- def _load_relation (self, relation_name: str) -> QueryBuilder[_ModelT]: ...
|