Removes the Model instance from the database. Sends pre_delete and post_delete signals. Sets model save status to False. Note it does not delete the Model itself (python object). So you can delete and later save (since pk is deleted no conflict will arise)
(self)
| 320 | return self |
| 321 | |
| 322 | async def delete(self) -> int: |
| 323 | """ |
| 324 | Removes the Model instance from the database. |
| 325 | |
| 326 | Sends pre_delete and post_delete signals. |
| 327 | |
| 328 | Sets model save status to False. |
| 329 | |
| 330 | Note it does not delete the Model itself (python object). |
| 331 | So you can delete and later save (since pk is deleted no conflict will arise) |
| 332 | or update and the Model will be saved in database again. |
| 333 | |
| 334 | :return: number of deleted rows (for some backends) |
| 335 | :rtype: int |
| 336 | """ |
| 337 | await self._emit_signal("pre_delete", instance=self) |
| 338 | expr = self.ormar_config.table.delete() |
| 339 | expr = expr.where(self.pk_column == (getattr(self, self.ormar_config.pkname))) |
| 340 | result = await self._execute_query(expr) |
| 341 | self.set_save_status(False) |
| 342 | await self._emit_signal("post_delete", instance=self) |
| 343 | return result |
| 344 | |
| 345 | async def load(self: T) -> T: |
| 346 | """ |