コード例 #1
0
    def get_or_none(cls: Type[MODEL], *args, **kwargs) -> FirstQuerySet[MODEL]:
        """
        Fetches a single record for a Model type using the provided filter parameters or None.

        .. code-block:: python3

            user = await User.get(username="******")
        """
        return QuerySet(cls).get_or_none(*args, **kwargs)
コード例 #2
0
    def get(cls: Type[MODEL], *args, **kwargs) -> GetQuerySet[MODEL]:
        """
        Fetches a single record for a Model type using the provided filter parameters.

        .. code-block:: python3

            user = await User.get(username="******")

        :raises MultipleObjectsReturned: If provided search returned more than one object.
        :raises DoesNotExist: If object can not be found.
        """
        return QuerySet(cls).get(*args, **kwargs)
コード例 #3
0
 def __init__(self, base: QuerySet, raw_sql: str):
     base._copy(self)
     self.raw_sql = raw_sql
コード例 #4
0
 def raw(cls: Type[MODEL], raw_sql) -> RawQuerySet[MODEL]:
     """
     Returns the complete QuerySet.
     """
     return QuerySet(cls).raw(raw_sql)
コード例 #5
0
 def all(cls: Type[MODEL]) -> QuerySet[MODEL]:
     """
     Returns the complete QuerySet.
     """
     return QuerySet(cls)
コード例 #6
0
 def annotate(cls: Type[MODEL], *args, **kwargs) -> QuerySet[MODEL]:
     return QuerySet(cls).annotate(*args, **kwargs)
コード例 #7
0
 def exclude(cls: Type[MODEL], *args, **kwargs) -> QuerySet[MODEL]:
     """
     Generates a QuerySet with the exclude applied.
     """
     return QuerySet(cls).exclude(*args, **kwargs)
コード例 #8
0
 def filter(cls: Type[MODEL], *args, **kwargs) -> QuerySet[MODEL]:
     """
     Generates a QuerySet with the filter applied.
     """
     return QuerySet(cls).filter(*args, **kwargs)
コード例 #9
0
 def first(cls: Type[MODEL]) -> FirstQuerySet[MODEL]:
     """
     Generates a QuerySet that returns the first record.
     """
     return QuerySet(cls).first()