Skip to content

Commit d0c4fb4

Browse files
authored
Merge pull request MongoEngine#2610 from bagerard/improve_doc_upd_agg_pipeline
improve doc related with recent change
2 parents 3160a80 + 67b2788 commit d0c4fb4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Development
1212
- Fix deepcopy of EmbeddedDocument #2202
1313
- Fix error when using precision=0 with DecimalField #2535
1414
- Add support for regex and whole word text search query #2568
15+
- Add support for update aggregation pipeline #2578
1516
- BREAKING CHANGE: Updates to support pymongo 4.0. Where possible deprecated
1617
functionality has been migrated, but additional care should be taken when
1718
migrating to pymongo 4.0 as existing code may have been using deprecated

docs/guide/querying.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,36 +218,35 @@ However, this doesn't map well to the syntax so you can also use a capital S ins
218218

219219
Raw queries
220220
-----------
221-
It is possible to provide a raw :mod:`PyMongo` query as a query parameter or update as a update parameter , which will
222-
be integrated directly into the query or update. This is done using the ``__raw__``
223-
keyword argument::
221+
It is possible to provide a raw :mod:`PyMongo` query as a query parameter, which will
222+
be integrated directly into the query. This is done using the ``__raw__`` keyword argument::
224223

225224
Page.objects(__raw__={'tags': 'coding'})
226225

227-
# or for update
228-
229-
Page.objects(__raw__={'tags': 'coding'}).update(__raw__={'$set': {'tags': 'coding'}})
226+
Similarly, a raw update can be provided to the :meth:`~mongoengine.queryset.QuerySet.update` method::
230227

231228
Page.objects(tags='coding').update(__raw__={'$set': {'tags': 'coding'}})
232229

233-
.. versionadded:: 0.4
230+
And the two can also be combined::
231+
232+
Page.objects(__raw__={'tags': 'coding'}).update(__raw__={'$set': {'tags': 'coding'}})
234233

235234

236235
Update with Aggregation Pipeline
237-
-----------
236+
--------------------------------
238237
It is possible to provide a raw :mod:`PyMongo` aggregation update parameter, which will
239-
be integrated directly into the update. This is done by using ``__raw__`` field and value of array
240-
pipeline
238+
be integrated directly into the update. This is done by using ``__raw__`` keyword argument to the update method
239+
and provide the pipeline as a list
241240
`Update with Aggregation Pipeline <https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#update-with-aggregation->`_
242-
keyword argument::
241+
::
243242

244243
# 'tags' field is set to 'coding is fun'
245244
Page.objects(tags='coding').update(__raw__=[
246245
{"$set": {"tags": {"$concat": ["$tags", "is fun"]}}}
247246
],
248247
)
249248

250-
.. versionadded:: 0.4
249+
.. versionadded:: 0.23.2
251250

252251
Sorting/Ordering results
253252
========================

0 commit comments

Comments
 (0)