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

Method delete_through_instance

ormar/relations/querysetproxy.py:169–181  ·  view source on GitHub ↗

Removes through model instance from the database for m2m relations. :param child: child model instance :type child: Model

(self, child: "T")

Source from the content-addressed store, hash-verified

167 await self.create_through_instance(child=child, **kwargs)
168
169 async def delete_through_instance(self, child: "T") -> None:
170 """
171 Removes through model instance from the database for m2m relations.
172
173 :param child: child model instance
174 :type child: Model
175 """
176 queryset = ormar.QuerySet(model_cls=self.relation.through) # type: ignore
177 owner_column = self.related_field.default_target_field_name() # type: ignore
178 child_column = self.related_field.default_source_field_name() # type: ignore
179 kwargs = {owner_column: self._owner, child_column: child}
180 link_instance = await queryset.filter(**kwargs).get() # type: ignore
181 await link_instance.delete()
182
183 async def exists(self) -> bool:
184 """

Callers 1

removeMethod · 0.80

Calls 5

filterMethod · 0.95
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected