Fields
beanie.odm.fields
Indexed
def Indexed(typ=None, index_type=ASCENDING, **kwargs)
If
typ
is defined, returns a subclass oftyp
with an extra attribute_indexed
as a tuple: - Index 0:index_type
such aspymongo.ASCENDING
- Index 1:kwargs
passed toIndexModel
When instantiated the type of the result will actually betyp
.When
typ
is not defined, returns anIndexedAnnotation
instance, to be used as metadata inAnnotated
fields.Example:
# Both fields would have the same behavior class MyModel(BaseModel): field1: Indexed(str, unique=True) field2: Annotated[str, Indexed(unique=True)]
PydanticObjectId
class PydanticObjectId(ObjectId)
Object Id field. Compatible with Pydantic.
ExpressionField
class ExpressionField(str)
ExpressionField.__getitem__
def __getitem__(item)
Get sub field
Arguments:
item
: name of the subfieldReturns:
ExpressionField
ExpressionField.__getattr__
def __getattr__(item)
Get sub field
Arguments:
item
: name of the subfieldReturns:
ExpressionField
LinkInfo
class LinkInfo(BaseModel)
LinkInfo.document_class
Document class
Link
class Link(Generic[T])
Link.fetch_list
@classmethod
async def fetch_list(cls,
links: List[Union["Link", "DocType"]],
fetch_links: bool = False)
Fetch list that contains links and documents
Arguments:
links
:fetch_links
:
BackLink
class BackLink(Generic[T])
Back reference to a document