@@ -218,36 +218,35 @@ However, this doesn't map well to the syntax so you can also use a capital S ins
218
218
219
219
Raw queries
220
220
-----------
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::
224
223
225
224
Page.objects(__raw__={'tags': 'coding'})
226
225
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::
230
227
231
228
Page.objects(tags='coding').update(__raw__={'$set': {'tags': 'coding'}})
232
229
233
- .. versionadded :: 0.4
230
+ And the two can also be combined::
231
+
232
+ Page.objects(__raw__={'tags': 'coding'}).update(__raw__={'$set': {'tags': 'coding'}})
234
233
235
234
236
235
Update with Aggregation Pipeline
237
- -----------
236
+ --------------------------------
238
237
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
241
240
`Update with Aggregation Pipeline <https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#update-with-aggregation- >`_
242
- keyword argument ::
241
+ ::
243
242
244
243
# 'tags' field is set to 'coding is fun'
245
244
Page.objects(tags='coding').update(__raw__=[
246
245
{"$set": {"tags": {"$concat": ["$tags", "is fun"]}}}
247
246
],
248
247
)
249
248
250
- .. versionadded :: 0.4
249
+ .. versionadded :: 0.23.2
251
250
252
251
Sorting/Ordering results
253
252
========================
0 commit comments