Projections

Note

PROJECTION, SHOW and HIDE are still exported for backwards compatibility reasons.

All of these classes are importable from alaric.projections

Projection

class alaric.projections.Projection(*fields: Show | Hide)

Specify that only the given fields should be returned from the query.

If you use Hide, the _id field will automatically also be hidden. If hiding _id is not desired, include Show("_id") in your Projection.

1# Assuming the data structure
2# {"_id": 1234, "prefix": "!", "has_premium": False}
3data: dict = await Document.find(
4    {"_id": "my_id"}, projections=Projection(Show("prefix"))
5)
6print(data)
7# Will print {"prefix": "!"}
build() Dict

Show

class alaric.projections.Show(*fields: Any)

Show this field in the returned data.

build() Dict

Hide

class alaric.projections.Hide(*fields: Any)

Hide this field in the returned data.

build() Dict