File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ or with an alias:
2121 conn = get_connection(' testdb' )
2222
2323 Example of test file:
24- --------
24+ ---------------------
2525.. code-block :: python
2626
2727 import unittest
Original file line number Diff line number Diff line change @@ -222,6 +222,18 @@ keyword argument::
222222
223223.. versionadded :: 0.4
224224
225+ Sorting/Ordering results
226+ ========================
227+ It is possible to order the results by 1 or more keys using :meth: `~mongoengine.queryset.QuerySet.order_by `.
228+ The order may be specified by prepending each of the keys by "+" or "-". Ascending order is assumed if there's no prefix.::
229+
230+ # Order by ascending date
231+ blogs = BlogPost.objects().order_by('date') # equivalent to .order_by('+date')
232+
233+ # Order by ascending date first, then descending title
234+ blogs = BlogPost.objects().order_by('+date', '-title')
235+
236+
225237Limiting and skipping results
226238=============================
227239Just as with traditional ORMs, you may limit the number of results returned or
@@ -585,7 +597,8 @@ cannot use the `$` syntax in keyword arguments it has been mapped to `S`::
585597 ['database', 'mongodb']
586598
587599From MongoDB version 2.6, push operator supports $position value which allows
588- to push values with index.
600+ to push values with index::
601+
589602 >>> post = BlogPost(title="Test", tags=["mongo"])
590603 >>> post.save()
591604 >>> post.update(push__tags__0=["database", "code"])
You can’t perform that action at this time.
0 commit comments