()
| 31 | |
| 32 | @create_drop_database(base_config=ormar_base_config) |
| 33 | async def run_query(): |
| 34 | await Book.objects.create( |
| 35 | title="Tom Sawyer", author="Twain, Mark", genre="Adventure" |
| 36 | ) |
| 37 | await Book.objects.create( |
| 38 | title="War and Peace in Space", author="Tolstoy, Leo", genre="Fantasy" |
| 39 | ) |
| 40 | await Book.objects.create( |
| 41 | title="Anna Karenina", author="Tolstoy, Leo", genre="Fiction" |
| 42 | ) |
| 43 | |
| 44 | # delete accepts kwargs that will be used in filter |
| 45 | # acting in same way as queryset.filter(**kwargs).delete() |
| 46 | await Book.objects.delete(genre="Fantasy") # delete all fantasy books |
| 47 | all_books = await Book.objects.all() |
| 48 | assert len(all_books) == 2 |
| 49 | |
| 50 | |
| 51 | asyncio.run(run_query()) |
no test coverage detected