Skip to content

Commit

Permalink
Better delete
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Nov 12, 2019
1 parent 71a325f commit f94d9ea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/async/async_http.py
Expand Up @@ -94,7 +94,7 @@ async def create_(self):
name = self.field("name", "John Doe")
person = Person(name = name)
await person.save_a()
person = await Person.get_a(name = name, map = True)
person = await Person.get_a(identifier = person.identifier, map = True)
return json.dumps(person)

@appier.route("/async/read", "GET")
Expand All @@ -107,9 +107,14 @@ async def read_(self):
async def delete_(self):
name = self.field("name", "John Doe")
persons = await Person.find_a(name = name)
person_c = len(persons)
await asyncio.gather(*[person.delete_a() for person in persons])
return json.dumps(dict(count = person_c))
persons_a = await Person.find_a(name = name)
return json.dumps(
dict(
before = len(persons),
after = len(persons_a)
)
)

app = AsyncHTTPApp()
app.serve()

0 comments on commit f94d9ea

Please sign in to comment.