99
1010from .bulk import BulkOperationsController
1111from .crud import CrudController
12- from .pagination import PaginationController , PaginationResult
13- from .performance import PerformanceController
1412from .query import QueryController
1513from .transaction import TransactionController
1614from .upsert import UpsertController
@@ -26,8 +24,8 @@ class BaseController[ModelT]:
2624 This controller delegates operations to specialized controllers while
2725 maintaining backward compatibility with the original BaseController API.
2826 Core CRUD and Query controllers are eagerly initialized, while specialized
29- controllers (pagination, bulk, transaction, performance, upsert) use lazy
30- initialization to reduce overhead for simple use cases.
27+ controllers (bulk, transaction, upsert) use lazy initialization to reduce
28+ overhead for simple use cases.
3129 """
3230
3331 def __init__ (self , model : type [ModelT ], db : DatabaseService | None = None ) -> None :
@@ -59,10 +57,8 @@ def __init__(self, model: type[ModelT], db: DatabaseService | None = None) -> No
5957 self ._query = QueryController (model , db )
6058
6159 # Specialized controllers - lazy initialization (reduces overhead)
62- self ._pagination : PaginationController [ModelT ] | None = None
6360 self ._bulk : BulkOperationsController [ModelT ] | None = None
6461 self ._transaction : TransactionController [ModelT ] | None = None
65- self ._performance : PerformanceController [ModelT ] | None = None
6662 self ._upsert : UpsertController [ModelT ] | None = None
6763
6864 # Properties for test compatibility
@@ -91,19 +87,6 @@ def model_class(self) -> type[ModelT]:
9187 return self .model
9288
9389 # Lazy initialization helpers
94- def _get_pagination (self ) -> PaginationController [ModelT ]:
95- """
96- Get or create pagination controller.
97-
98- Returns
99- -------
100- PaginationController[ModelT]
101- The pagination controller instance.
102- """
103- if self ._pagination is None :
104- self ._pagination = PaginationController (self .model , self .db )
105- return self ._pagination
106-
10790 def _get_bulk (self ) -> BulkOperationsController [ModelT ]:
10891 """
10992 Get or create bulk operations controller.
@@ -130,19 +113,6 @@ def _get_transaction(self) -> TransactionController[ModelT]:
130113 self ._transaction = TransactionController (self .model , self .db )
131114 return self ._transaction
132115
133- def _get_performance (self ) -> PerformanceController [ModelT ]:
134- """
135- Get or create performance controller.
136-
137- Returns
138- -------
139- PerformanceController[ModelT]
140- The performance controller instance.
141- """
142- if self ._performance is None :
143- self ._performance = PerformanceController (self .model , self .db )
144- return self ._performance
145-
146116 def _get_upsert (self ) -> UpsertController [ModelT ]:
147117 """
148118 Get or create upsert controller.
@@ -312,109 +282,6 @@ async def execute_query(self, query: Any) -> Any:
312282 """
313283 return await self ._query .execute_query (query )
314284
315- async def find_with_json_query (
316- self ,
317- json_column : str ,
318- json_path : str ,
319- value : Any ,
320- filters : Any | None = None ,
321- ) -> list [ModelT ]:
322- """
323- Find records using JSON column queries.
324-
325- Returns
326- -------
327- list[ModelT]
328- List of records matching the JSON query.
329- """
330- return await self ._query .find_with_json_query (
331- json_column ,
332- json_path ,
333- value ,
334- filters ,
335- )
336-
337- async def find_with_array_contains (
338- self ,
339- array_column : str ,
340- value : Any ,
341- filters : Any | None = None ,
342- ) -> list [ModelT ]:
343- """
344- Find records where array column contains value.
345-
346- Returns
347- -------
348- list[ModelT]
349- List of records with matching array values.
350- """
351- return await self ._query .find_with_array_contains (array_column , value , filters )
352-
353- async def find_with_full_text_search (
354- self ,
355- search_columns : list [str ],
356- search_term : str ,
357- filters : Any | None = None ,
358- ) -> list [ModelT ]:
359- """
360- Find records using full-text search.
361-
362- Returns
363- -------
364- list[ModelT]
365- List of records matching the search term.
366- """
367- return await self ._query .find_with_full_text_search (
368- search_columns ,
369- search_term ,
370- filters ,
371- )
372-
373- # ------------------------------------------------------------------
374- # Pagination Methods - Lazy-loaded
375- # ------------------------------------------------------------------
376-
377- async def paginate (
378- self ,
379- page : int = 1 ,
380- per_page : int = 20 ,
381- filters : Any | None = None ,
382- order_by : Any | None = None ,
383- ) -> PaginationResult [ModelT ]:
384- """
385- Paginate records with metadata.
386-
387- Returns
388- -------
389- PaginationResult[ModelT]
390- Pagination result with items, total, and page info.
391- """
392- return await self ._get_pagination ().paginate (page , per_page , filters , order_by )
393-
394- async def find_paginated (
395- self ,
396- page : int = 1 ,
397- per_page : int = 20 ,
398- filters : Any | None = None ,
399- order_by : Any | None = None ,
400- load_relationships : list [str ] | None = None ,
401- ) -> PaginationResult [ModelT ]:
402- """
403- Find paginated records with relationship loading.
404-
405- Returns
406- -------
407- PaginationResult[ModelT]
408- Pagination result with items and relationships loaded.
409- """
410- return await self ._get_pagination ().find_paginated (
411- page ,
412- per_page ,
413- filters ,
414- order_by ,
415- load_relationships ,
416- )
417-
418285 # ------------------------------------------------------------------
419286 # Bulk Operations - Lazy-loaded
420287 # ------------------------------------------------------------------
@@ -474,26 +341,6 @@ async def delete_where(self, filters: Any) -> int:
474341 """
475342 return await self ._get_bulk ().delete_where (filters )
476343
477- async def bulk_upsert_with_conflict_resolution (
478- self ,
479- items : list [dict [str , Any ]],
480- conflict_columns : list [str ],
481- update_columns : list [str ] | None = None ,
482- ) -> list [ModelT ]:
483- """
484- Bulk upsert with conflict resolution.
485-
486- Returns
487- -------
488- list[ModelT]
489- List of upserted records.
490- """
491- return await self ._get_bulk ().bulk_upsert_with_conflict_resolution (
492- items ,
493- conflict_columns ,
494- update_columns ,
495- )
496-
497344 # ------------------------------------------------------------------
498345 # Transaction Methods - Lazy-loaded
499346 # ------------------------------------------------------------------
@@ -531,41 +378,6 @@ async def execute_transaction(self, callback: Callable[[], Any]) -> Any:
531378 """
532379 return await self ._get_transaction ().execute_transaction (callback )
533380
534- # ------------------------------------------------------------------
535- # Performance Methods - Lazy-loaded
536- # ------------------------------------------------------------------
537-
538- async def get_table_statistics (self ) -> dict [str , Any ]:
539- """
540- Get comprehensive table statistics.
541-
542- Returns
543- -------
544- dict[str, Any]
545- Dictionary containing table statistics.
546- """
547- return await self ._get_performance ().get_table_statistics ()
548-
549- async def explain_query_performance (
550- self ,
551- query : Any ,
552- analyze : bool = False ,
553- buffers : bool = False ,
554- ) -> dict [str , Any ]:
555- """
556- Explain query performance with optional analysis.
557-
558- Returns
559- -------
560- dict[str, Any]
561- Dictionary containing query execution plan and statistics.
562- """
563- return await self ._get_performance ().explain_query_performance (
564- query ,
565- analyze ,
566- buffers ,
567- )
568-
569381 # ------------------------------------------------------------------
570382 # Upsert Methods - Lazy-loaded
571383 # ------------------------------------------------------------------
0 commit comments