From dd266b2b52fe7f4a187d4a90ae010faf0a9fdf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20S=C3=A1nchez?= Date: Tue, 25 May 2021 18:20:41 -0500 Subject: [PATCH] async_update --- mongoengine_plus/aio/async_query_set.py | 3 +++ mongoengine_plus/version.py | 2 +- tests/aio/test_async_query_set.py | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mongoengine_plus/aio/async_query_set.py b/mongoengine_plus/aio/async_query_set.py index 2b3c5f7..fd3e1b6 100644 --- a/mongoengine_plus/aio/async_query_set.py +++ b/mongoengine_plus/aio/async_query_set.py @@ -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) diff --git a/mongoengine_plus/version.py b/mongoengine_plus/version.py index 909f874..d326f7e 100644 --- a/mongoengine_plus/version.py +++ b/mongoengine_plus/version.py @@ -1 +1 @@ -__version__ = '0.0.3.dev1' +__version__ = '0.0.3.dev2' diff --git a/tests/aio/test_async_query_set.py b/tests/aio/test_async_query_set.py index 74f8447..d82062b 100644 --- a/tests/aio/test_async_query_set.py +++ b/tests/aio/test_async_query_set.py @@ -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'