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)
| 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 | """ |
no test coverage detected