codemation / pydbantic

A single model for shaping, creating, accessing, storing data within a Database
https://pydbantic.readthedocs.io/en/latest/
Apache License 2.0
223 stars 16 forks source link

Feature - DataBaseModel Count and filter count #21

Closed codemation closed 2 years ago

codemation commented 2 years ago

Description

This PR implements DataBaseModel .count() method to more efficiently determine a total number of objects, and integrated the same logic into .filter(count_rows=True) which causes filter to return an integer count objects matching a given set of filters.

employee_count = await Employees.count()

employed_count = await Employees.filter(
      is_employed=True,
      count_rows=True
)