ぼざろクリーチャーシリーズ 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.
 
 
 

114 lines
2.9 KiB

  1. from __future__ import annotations
  2. from typing import Any, Generic, Type, TypeVar, overload
  3. from eloquent.orm.relations.dynamic_property import DynamicProperty
  4. _TModel = TypeVar ('_TModel', bound = 'Model')
  5. class Connection:
  6. def select (self, query: str, bindings: dict[str, Any] | None = None) -> Any: ...
  7. def insert (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  8. def update (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  9. def delete (self, query: str, bindings: dict[str, Any] | None = None) -> int: ...
  10. def transaction (self, callback: Any) -> Any: ...
  11. def begin_transaction (self) -> None: ...
  12. def commit (self) -> None: ...
  13. def rollback (self) -> None: ...
  14. class ConnectionResolver:
  15. def connection (self, name: str | None = None) -> Any: ...
  16. def get_default_connection (self) -> str: ...
  17. def set_default_connection (self, name: str) -> None: ...
  18. class DatabaseManager:
  19. connections: dict[str, Connection]
  20. def __init__ (self, config: dict[str, Any]) -> None: ...
  21. def connection (self, name: str | None = None) -> Connection: ...
  22. def disconnect (self, name: str | None = None) -> None: ...
  23. def reconnect (self, name: str | None = None) -> Connection: ...
  24. def get_connections (self) -> dict[str, Connection]: ...
  25. class Model:
  26. id: int
  27. def has_one (
  28. self,
  29. related_model: Type[Model],
  30. foreign_key: str | None = None,
  31. ) -> DynamicProperty: ...
  32. def has_many (
  33. self,
  34. related_model: Type[Model],
  35. foreign_key: str | None = None,
  36. ) -> DynamicProperty: ...
  37. def belongs_to (
  38. self,
  39. related_model: Type[Model],
  40. foreign_key: str | None = None,
  41. ) -> DynamicProperty: ...
  42. def belongs_to_many (
  43. self,
  44. related_model: Type[Model],
  45. foreign_key: str | None = None,
  46. ) -> DynamicProperty: ...
  47. def save (self) -> None: ...
  48. def delete (self) -> None: ...
  49. @classmethod
  50. def find (cls, id: int) -> Model | None: ...
  51. @overload
  52. @classmethod
  53. def where (cls, field: str, operator: str, value: Any) -> QueryBuilder: ...
  54. @overload
  55. @classmethod
  56. def where (cls, field: str, value: Any) -> QueryBuilder: ...
  57. @classmethod
  58. def where_not_in (cls, column: str, values: list[Any] | tuple) -> QueryBuilder: ...
  59. @classmethod
  60. def where_not_null (cls, field: str) -> QueryBuilder: ...
  61. @classmethod
  62. def set_connection_resolver (cls, resolver: DatabaseManager) -> None: ...
  63. class QueryBuilder (Generic[_TModel]):
  64. def first (self) -> _TModel | None: ...
  65. def get (self) -> list[_TModel]: ...
  66. @overload
  67. def where (self, field: str, operator: str, value: Any) -> QueryBuilder: ...
  68. @overload
  69. def where (self, field: str, value: Any) -> QueryBuilder: ...
  70. def where_null (self, field: str) -> QueryBuilder: ...