Gets the first row from the db ordered by primary key column ascending. Behaves like :meth:`first` but returns ``None`` instead of raising ``NoMatch`` when no row matches. :param kwargs: fields names and proper value types :type kwargs: Any :return:
(self, *args: Any, **kwargs: Any)
| 1065 | return await self._fetch_single(self._single_row_order_bys(reverse=False)) |
| 1066 | |
| 1067 | async def first_or_none(self, *args: Any, **kwargs: Any) -> Optional["T"]: |
| 1068 | """ |
| 1069 | Gets the first row from the db ordered by primary key column ascending. |
| 1070 | |
| 1071 | Behaves like :meth:`first` but returns ``None`` instead of raising |
| 1072 | ``NoMatch`` when no row matches. |
| 1073 | |
| 1074 | :param kwargs: fields names and proper value types |
| 1075 | :type kwargs: Any |
| 1076 | :return: returned model or None |
| 1077 | :rtype: Optional[Model] |
| 1078 | """ |
| 1079 | try: |
| 1080 | return await self.first(*args, **kwargs) |
| 1081 | except ormar.NoMatch: |
| 1082 | return None |
| 1083 | |
| 1084 | async def last(self, *args: Any, **kwargs: Any) -> "T": |
| 1085 | """ |