@@ -0,0 +1,140 @@ | |||||
# 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]: ... |
@@ -9,7 +9,7 @@ from __future__ import annotations | |||||
from datetime import date, datetime | from datetime import date, datetime | ||||
from my_eloquent import Model | |||||
from db.my_eloquent import Model | |||||
class Comment (Model): | class Comment (Model): |
@@ -1,140 +0,0 @@ | |||||
# 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]: ... |
@@ -0,0 +1 @@ | |||||
db/eloquent.pyi |
@@ -20,7 +20,7 @@ import jaconv | |||||
import requests | import requests | ||||
from eloquent import DatabaseManager, Model | from eloquent import DatabaseManager, Model | ||||
from models import Comment, Tag, User, Video, VideoHistory, VideoTag | |||||
from db.models import Comment, Tag, User, Video, VideoHistory, VideoTag | |||||
def main ( | def main ( | ||||