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

Method update_through_instance

ormar/relations/querysetproxy.py:138–152  ·  view source on GitHub ↗

Updates a through model instance in the database for m2m relations. :param kwargs: dict of additional keyword arguments for through instance :type kwargs: Any :param child: child model instance :type child: Model

(self, child: "T", **kwargs: Any)

Source from the content-addressed store, hash-verified

136 await model_cls(**final_kwargs).save()
137
138 async def update_through_instance(self, child: "T", **kwargs: Any) -> None:
139 """
140 Updates a through model instance in the database for m2m relations.
141
142 :param kwargs: dict of additional keyword arguments for through instance
143 :type kwargs: Any
144 :param child: child model instance
145 :type child: Model
146 """
147 model_cls = self.relation.through
148 owner_column = self.related_field.default_target_field_name() # type: ignore
149 child_column = self.related_field.default_source_field_name() # type: ignore
150 rel_kwargs = {owner_column: self._owner.pk, child_column: child.pk}
151 through_model = await model_cls.objects.get(**rel_kwargs)
152 await through_model.update(**kwargs)
153
154 async def upsert_through_instance(self, child: "T", **kwargs: Any) -> None:
155 """

Callers 2

updateMethod · 0.95

Calls 4

getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected