Clear ORM
Search…
Aggregation
Each collection have simple access to aggregation functions.

MIN, MAX, AVG and SUM

By default, min, max, avg, sum and count are mapped:
1
user_count = User.query.count
2
3
user_max_id = User.query.max("id", Int64)
4
user_min_id = User.query.min("id", Int64)
5
6
user_average_time = User.query.avg("time_connected", Float64)
Copied!

Custom aggregation method

You can call you own custom aggregation method using agg method:
1
time_squared = User.query.agg("AVG(timesquared * timesquared)", Float64)
Copied!
Last modified 1yr ago