| 244 | return conditions |
| 245 | |
| 246 | async def count(self, filters: Optional[Dict] = None) -> int: |
| 247 | await self.prepare() |
| 248 | |
| 249 | async def operation(session: AsyncSession): |
| 250 | stmt = select(func.count()).select_from(self.table_model_cls) |
| 251 | conditions = self._build_filter_conditions(filters) |
| 252 | if conditions: |
| 253 | stmt = stmt.where(and_(*conditions)) |
| 254 | result = await session.execute(stmt) |
| 255 | return result.scalar() |
| 256 | |
| 257 | return await async_run_with_retry_session( |
| 258 | self.session, operation, self.max_retry_times, self.max_retry_interval |
| 259 | ) |
| 260 | |
| 261 | async def query( |
| 262 | self, offset: int = 0, limit: int = 10, filters: Optional[Dict] = None |