File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 2
2
Retrieve documents that match "New York" in the "city" field,
3
3
sorted by the "name" field by using the German collation.
4
4
*/
5
+ // start find sort collation
5
6
myColl . find ( { city : "New York" } , { collation : { locale : "de" } } )
6
7
. sort ( { name : 1 } ) ;
8
+ // end find sort collation
Original file line number Diff line number Diff line change 3
3
locale collation, specifying ascending ordering of the
4
4
"title" field.
5
5
*/
6
- // start index collation
6
+ // start create index collation
7
7
myColl . createIndex (
8
8
{ 'title' : 1 } ,
9
9
{ 'collation' : { 'locale' : 'en_US' } } ) ;
10
- // end index collation
10
+ // end create index collation
Original file line number Diff line number Diff line change 3
3
in descending order of the value of the "title" field,
4
4
specifying a collation that uses the index.
5
5
*/
6
+ // start query index collation
6
7
myColl . find ( { "year" : 1980 } , { "collation" : { "locale" : "en_US" } } )
7
- . sort ( { "title" : - 1 } ) ;
8
+ . sort ( { "title" : - 1 } ) ;
9
+ // end query index collation
Original file line number Diff line number Diff line change @@ -149,13 +149,15 @@ a collection with a collation set to the "``en_US``" locale.
149
149
150
150
.. literalinclude:: /code-snippets/collation/index-collation.js
151
151
:language: javascript
152
- :start-after: start indexcollation
153
- :end-before: end indexcollation
152
+ :start-after: start create index collation
153
+ :end-before: end create index collation
154
154
155
155
The following query uses the index we created:
156
156
157
157
.. literalinclude:: /code-snippets/collation/query-index-collation.js
158
158
:language: javascript
159
+ :start-after: start query index collation
160
+ :end-before: end query index collation
159
161
160
162
The following queries **do not** use the index that we created. The first
161
163
query does not include a collation and the second contains a different
@@ -188,6 +190,8 @@ setting the value of the ``locale`` parameter to ``de``.
188
190
189
191
.. literalinclude:: /code-snippets/collation/find-sort-collation.js
190
192
:language: javascript
193
+ :start-after: start find sort collation
194
+ :end-before: end find sort collation
191
195
192
196
findOneAndUpdate() Example
193
197
``````````````````````````
You can’t perform that action at this time.
0 commit comments