Skip to content

Commit

Permalink
async_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Sánchez committed May 25, 2021
1 parent 9b72875 commit dd266b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mongoengine_plus/aio/async_query_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ async def async_count(self, with_limit_and_skip=False):

async def async_to_list(self):
return await create_awaitable(list, self)

async def async_update(self, *u_objs, **query):
return await create_awaitable(self.update, *u_objs, **query)
2 changes: 1 addition & 1 deletion mongoengine_plus/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.3.dev1'
__version__ = '0.0.3.dev2'
9 changes: 9 additions & 0 deletions tests/aio/test_async_query_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ async def test_to_list(cities):
async def test_first(cities):
first_city = await City.objects(state='Tabasco').async_first()
assert first_city.state == 'Tabasco'


@pytest.mark.asyncio
async def test_update(cities):
await City.objects(name='San Cristobal').async_update(
set__name='San Cristobal de las Casas'
)
sancris = await City.objects.async_get(name__contains='San Cristobal')
assert sancris.name == 'San Cristobal de las Casas'

0 comments on commit dd266b2

Please sign in to comment.