ぼざろクリーチャーシリーズ DB 兼 API(自分用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eloquent.pyi 3.5 KiB

1 week ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # pylint: disable = missing-class-docstring
  2. # pylint: disable = missing-function-docstring
  3. # pylint: disable = missing-module-docstring
  4. # pylint: disable = unused-argument
  5. from __future__ import annotations
  6. from typing import Any, Generic, Type, TypeVar, overload
  7. from typing_extensions import Self
  8. _ModelT = TypeVar ('_ModelT', bound = 'Model')
  9. class Connection:
  10. def select (self, query: str, bindings: dict[str, Any] | None = None) -> Any: ...
  11. def insert (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  12. def update (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  13. def delete (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  14. def transaction (self, callback: Any) -> Any: ...
  15. def begin_transaction (self) -> None: ...
  16. def commit (self) -> None: ...
  17. def rollback (self) -> None: ...
  18. class ConnectionResolver:
  19. def connection (self, name: str | None = None) -> Any: ...
  20. def get_default_connection (self) -> str: ...
  21. def set_default_connection (self, name: str) -> None: ...
  22. class DatabaseManager:
  23. connections: dict[str, Connection]
  24. def __init__ (self, config: dict[str, Any]) -> None: ...
  25. def connection (self, name: str | None = None) -> Connection: ...
  26. def disconnect (self, name: str | None = None) -> None: ...
  27. def reconnect (self, name: str | None = None) -> Connection: ...
  28. def get_connections (self) -> dict[str, Connection]: ...
  29. class Model:
  30. id: int
  31. _Model__exists: bool
  32. def has_one (
  33. self,
  34. related_model: Type[_ModelT],
  35. foreign_key: str | None = None,
  36. ) -> _ModelT: ...
  37. def has_many (
  38. self,
  39. related_model: Type[_ModelT],
  40. foreign_key: str | None = None,
  41. ) -> list[_ModelT]: ...
  42. def belongs_to (
  43. self,
  44. related_model: Type[_ModelT],
  45. foreign_key: str | None = None,
  46. ) -> _ModelT: ...
  47. def belongs_to_many (
  48. self,
  49. related_model: Type[_ModelT],
  50. foreign_key: str | None = None,
  51. ) -> list[_ModelT]: ...
  52. def save (self) -> None: ...
  53. def delete (self) -> None: ...
  54. @classmethod
  55. def find (cls, id_: int) -> Self | None: ...
  56. @classmethod
  57. def query (
  58. cls,
  59. ) -> QueryBuilder[Self]: ...
  60. @overload
  61. @classmethod
  62. def where (
  63. cls,
  64. field: str,
  65. operator: str,
  66. value: Any,
  67. ) -> QueryBuilder[Self]: ...
  68. @overload
  69. @classmethod
  70. def where (cls, field: str, value: Any) -> QueryBuilder[Self]: ...
  71. @classmethod
  72. def where_not_in (
  73. cls,
  74. column: str,
  75. values: list[Any] | tuple
  76. ) -> QueryBuilder[Self]: ...
  77. @classmethod
  78. def where_not_null (cls, field: str) -> QueryBuilder[Self]: ...
  79. @classmethod
  80. def set_connection_resolver (cls, resolver: DatabaseManager) -> None: ...
  81. class QueryBuilder (Generic[_ModelT]):
  82. def first (self) -> _ModelT | None: ...
  83. def get (self) -> list[_ModelT]: ...
  84. @overload
  85. def where (
  86. self,
  87. field: str,
  88. operator: str,
  89. value: Any,
  90. ) -> QueryBuilder[_ModelT]: ...
  91. @overload
  92. def where (self, field: str, value: Any) -> QueryBuilder[_ModelT]: ...
  93. def where_null (self, field: str) -> QueryBuilder[_ModelT]: ...
  94. def _load_relation (self, relation_name: str) -> QueryBuilder[_ModelT]: ...