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
_idfield will automatically also be hidden. If hiding_idis not desired, includeShow("_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": "!"}