MCPcopy
hub / github.com/ormar-orm/ormar / values_list

Method values_list

ormar/queryset/queryset.py:731–761  ·  view source on GitHub ↗

Return a list of tuples with column values in order of the fields passed or all fields from queried models. When one field is passed you can flatten the list of tuples into list of values of that single field. To filter for given row use filter/exclude meth

(
        self,
        fields: Union[list, str, set, dict, None] = None,
        flatten: bool = False,
        exclude_through: bool = False,
    )

Source from the content-addressed store, hash-verified

729 return tuple_result if not _flatten else [x[0] for x in tuple_result]
730
731 async def values_list(
732 self,
733 fields: Union[list, str, set, dict, None] = None,
734 flatten: bool = False,
735 exclude_through: bool = False,
736 ) -> list:
737 """
738 Return a list of tuples with column values in order of the fields passed or
739 all fields from queried models.
740
741 When one field is passed you can flatten the list of tuples into list of values
742 of that single field.
743
744 To filter for given row use filter/exclude methods before values,
745 to limit number of rows use limit/offset or paginate before values.
746
747 Note that it always return a list even for one row from database.
748
749 :param exclude_through: flag if through models should be excluded
750 :type exclude_through: bool
751 :param fields: field name or list of field names to extract from db
752 :type fields: Union[str, list[str]]
753 :param flatten: when one field is passed you can flatten the list of tuples
754 :type flatten: bool
755 """
756 return await self.values(
757 fields=fields,
758 exclude_through=exclude_through,
759 _as_dict=False,
760 _flatten=flatten,
761 )
762
763 async def exists(self) -> bool:
764 """

Calls 1

valuesMethod · 0.95