Gets the last row from the db ordered by primary key column descending. Complementary to :meth:`first`: the default pk ordering is flipped and the top row is returned. Passing args and/or kwargs is a shortcut and equals to calling ``filter(*args, **kwargs).last()``.
(self, *args: Any, **kwargs: Any)
| 1082 | return None |
| 1083 | |
| 1084 | async def last(self, *args: Any, **kwargs: Any) -> "T": |
| 1085 | """ |
| 1086 | Gets the last row from the db ordered by primary key column descending. |
| 1087 | |
| 1088 | Complementary to :meth:`first`: the default pk ordering is flipped |
| 1089 | and the top row is returned. Passing args and/or kwargs is a shortcut |
| 1090 | and equals to calling ``filter(*args, **kwargs).last()``. |
| 1091 | |
| 1092 | The query is always executed with ``LIMIT 1`` so at most one row is |
| 1093 | fetched; use :meth:`get` if you want to assert that the criteria |
| 1094 | match exactly one row. |
| 1095 | |
| 1096 | :raises NoMatch: if no rows match the criteria |
| 1097 | :param kwargs: fields names and proper value types |
| 1098 | :type kwargs: Any |
| 1099 | :return: returned model |
| 1100 | :rtype: Model |
| 1101 | """ |
| 1102 | if kwargs or args: |
| 1103 | return await self.filter(*args, **kwargs).last() |
| 1104 | return await self._fetch_single(self._single_row_order_bys(reverse=True)) |
| 1105 | |
| 1106 | async def last_or_none(self, *args: Any, **kwargs: Any) -> Optional["T"]: |
| 1107 | """ |