6. avg()
This is a utility function that comes within the loom object that is used to calculate the average value in rows of data in a database table that meets a specific criteria. Here is an example on how to use this utility function.
# example
_avg = mysql_loom.avg(
instance=Post,
filters=Filter(
column="id",
operator="between",
value=[1, 7],
),
column="id",
limit=3,
offset=0,
distinct=True,
)
print(_avg)
The max function takes the following arguments:
.. rst-class:: my-table
Argument |
Description |
|---|---|
|
The model class to retrieve documents from. |
|
A string of column to calculate average values based on. |
|
Maximum number of documents to retrieve. |
|
Number of documents to skip before finding the calculating the average. |
|
Collection of |
|
Boolean telling |