Skip to content

Commit

Permalink
database.table_view:View.count - add method to count elements
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Dec 25, 2024
1 parent 0cc58b3 commit d7d0593
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions acacore/database/table_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,22 @@ def select(
:return: A ``Cursor`` instance.
"""
return self._table.select(where, params, order_by, limit, offset)

def count(
self,
where: _W | None = None,
params: list[SQLValue] | None = None,
limit: int | None = None,
offset: int | None = None,
) -> int:
"""
Count entries from the view.
:param where: The where statement to use. This can be a string or a dictionary containing column names and values.
:param params: The parameters to use for the query, they are ignored if the ``where`` argument is anything but
a string.
:param limit: The maximum number of results to return.
:param offset: The offset to start the results from.
:return: A ``Cursor`` instance.
"""
return self._table.count(where, params, limit, offset)

0 comments on commit d7d0593

Please sign in to comment.