Rules
mongo_ops.populate.rules
Summary
Populate rules describing which foreign-key fields to resolve.
Classes
PopulateRule
dataclass
Describes how a foreign-key field resolves to another collection.
A rule declares the field to resolve, the collection its references point at, and optional nested rules applied to the referenced document itself. It also bounds how deep the resolution may recurse.
Attributes:
| Name | Type | Description |
|---|---|---|
field_name |
str
|
Name of the FK field on the source document. |
collection_name |
str
|
Collection the reference points into. |
nested_rules |
Optional[list[PopulateRule]]
|
Sub-rules applied to the referenced document. Defaults to None. |
max_depth |
int
|
Maximum recursion depth for this rule. Defaults to 1. |
filter |
Optional[dict[str, Any]]
|
Optional Mongo filter applied when fetching the reference. Defaults to None. |
projection |
Optional[dict[str, Any]]
|
Optional Mongo projection applied when fetching the reference. Defaults to None. |