Skip to content

Commit dd266b2

Browse files
author
Ricardo Sánchez
committed
async_update
1 parent 9b72875 commit dd266b2

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

mongoengine_plus/aio/async_query_set.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ async def async_count(self, with_limit_and_skip=False):
1515

1616
async def async_to_list(self):
1717
return await create_awaitable(list, self)
18+
19+
async def async_update(self, *u_objs, **query):
20+
return await create_awaitable(self.update, *u_objs, **query)

mongoengine_plus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.3.dev1'
1+
__version__ = '0.0.3.dev2'

tests/aio/test_async_query_set.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ async def test_to_list(cities):
3131
async def test_first(cities):
3232
first_city = await City.objects(state='Tabasco').async_first()
3333
assert first_city.state == 'Tabasco'
34+
35+
36+
@pytest.mark.asyncio
37+
async def test_update(cities):
38+
await City.objects(name='San Cristobal').async_update(
39+
set__name='San Cristobal de las Casas'
40+
)
41+
sancris = await City.objects.async_get(name__contains='San Cristobal')
42+
assert sancris.name == 'San Cristobal de las Casas'

0 commit comments

Comments
 (0)