File: aggregation.py

package info (click to toggle)
python-beanie 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,480 kB
  • sloc: python: 14,427; makefile: 7; sh: 6
file content (21 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from typing import Any, Dict, List

from tests.typing.models import ProjectionTest, Test


async def aggregate() -> List[Dict[str, Any]]:
    result = await Test.aggregate([]).to_list()
    result_2 = await Test.find().aggregate([]).to_list()
    return result or result_2


async def aggregate_with_projection() -> List[ProjectionTest]:
    result = (
        await Test.find()
        .aggregate([], projection_model=ProjectionTest)
        .to_list()
    )
    result_2 = await Test.aggregate(
        [], projection_model=ProjectionTest
    ).to_list()
    return result or result_2