예제 #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()