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

Method upsert_through_instance

ormar/relations/querysetproxy.py:154–167  ·  view source on GitHub ↗

Updates a through model instance in the database for m2m relations if it already exists, else creates one. :param kwargs: dict of additional keyword arguments for through instance :type kwargs: Any :param child: child model instance :type child: Mode

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

Source from the content-addressed store, hash-verified

152 await through_model.update(**kwargs)
153
154 async def upsert_through_instance(self, child: "T", **kwargs: Any) -> None:
155 """
156 Updates a through model instance in the database for m2m relations if
157 it already exists, else creates one.
158
159 :param kwargs: dict of additional keyword arguments for through instance
160 :type kwargs: Any
161 :param child: child model instance
162 :type child: Model
163 """
164 try:
165 await self.update_through_instance(child=child, **kwargs)
166 except NoMatch:
167 await self.create_through_instance(child=child, **kwargs)
168
169 async def delete_through_instance(self, child: "T") -> None:
170 """

Callers 1

_upsert_through_modelMethod · 0.80

Calls 2

Tested by

no test coverage detected