@@ -120,26 +120,26 @@ collection.
120
120
121
121
.. literalinclude:: /code-snippets/collation/collection-collation.js
122
122
:language: javascript
123
- :start-after: start create collection with collation
124
- :end-before: end create collection with collation
123
+ :start-after: start collection collation
124
+ :end-before: end collection collation
125
125
126
126
Any of the operations that support collations automatically apply the collation
127
127
defined on the collection. The query below searches the ``souvenirs``
128
128
collection and applies the "``fr_CA``" locale collation:
129
129
130
- .. literalinclude:: /code-snippets/collation/collection-collation.js
130
+ .. literalinclude:: /code-snippets/collation/collection-auto- collation.js
131
131
:language: javascript
132
- :start-after: start collection query without collation
133
- :end-before: end collection query without collation
132
+ :start-after: start auto collation
133
+ :end-before: end auto collation
134
134
135
135
You can specify a different collation as a parameter in an operation that
136
136
supports collations. The following query specifies the "``is``" Iceland locale
137
137
and ``caseFirst`` optional parameter with the value "``upper``":
138
138
139
- .. literalinclude:: /code-snippets/collation/collection-collation.js
139
+ .. literalinclude:: /code-snippets/collation/collection-specify- collation.js
140
140
:language: javascript
141
- :start-after: start collection query with collation
142
- :end-before: end collection query with collation
141
+ :start-after: start specified collation
142
+ :end-before: end specified collation
143
143
144
144
Assign a Collation to an Index
145
145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -149,6 +149,8 @@ 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 create index collation
153
+ :end-before: end create index collation
152
154
153
155
The following query uses the index we created:
154
156
@@ -157,14 +159,19 @@ The following query uses the index we created:
157
159
:start-after: start query index collation
158
160
:end-before: end query index collation
159
161
160
- The following queries **do not** use the index that we created. The first
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
162
164
strength value than the collation on the index.
163
165
164
- .. literalinclude:: /code-snippets/collation/query-index -collation.js
166
+ .. literalinclude:: /code-snippets/collation/query-not-indexed -collation.js
165
167
:language: javascript
166
- :start-after: start query without index collation
167
- :end-before: end query without index collation
168
+ :start-after: start not indexed collation
169
+ :end-before: end not indexed collation
170
+
171
+ .. literalinclude:: /code-snippets/collation/query-index-no-collation.js
172
+ :language: javascript
173
+ :start-after: start index no collation
174
+ :end-before: end index no collation
168
175
169
176
Collation Query Examples
170
177
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -183,6 +190,8 @@ setting the value of the ``locale`` parameter to ``de``.
183
190
184
191
.. literalinclude:: /code-snippets/collation/find-sort-collation.js
185
192
:language: javascript
193
+ :start-after: start find sort collation
194
+ :end-before: end find sort collation
186
195
187
196
findOneAndUpdate() Example
188
197
``````````````````````````
@@ -201,10 +210,10 @@ following documents:
201
210
Consider the following ``findOneAndUpdate()`` operation on this collection
202
211
which **does not** specify a collation:
203
212
204
- .. literalinclude:: /code-snippets/collation/findOneAndUpdate-collation.js
213
+ .. literalinclude:: /code-snippets/collation/findOneAndUpdate-default-order- collation.js
205
214
:language: javascript
206
- :start-after: start findOneAndUpdate without collation
207
- :end-before: end findOneAndUpdate without collation
215
+ :start-after: start findOneAndUpdate default order collation
216
+ :end-before: end findOneAndUpdate default order collation
208
217
209
218
Since "Gunter" is the first sorted result when using a binary collation, none
210
219
of the documents come lexically before and match the ``$lt`` comparison
@@ -220,8 +229,8 @@ umlauts.
220
229
221
230
.. literalinclude:: /code-snippets/collation/findOneAndUpdate-collation.js
222
231
:language: javascript
223
- :start-after: start findOneAndUpdate with collation
224
- :end-before: end findOneAndUpdate with collation
232
+ :start-after: start findOneAndUpdate collation
233
+ :end-before: end findOneAndUpdate collation
225
234
226
235
Since "Günter" lexically comes before "Gunter" using the
227
236
``de@collation=phonebook`` collation specified in ``findOneAndUpdate()``,
@@ -252,8 +261,8 @@ lexical order.
252
261
253
262
.. literalinclude:: /code-snippets/collation/findOneAndDelete-collation.js
254
263
:language: javascript
255
- :start-after: start findOneAndDelete example with collation
256
- :end-before: end findOneAndDelete example with collation
264
+ :start-after: start findOneAndDelete collation
265
+ :end-before: end findOneAndDelete collation
257
266
258
267
After you run the operation above, the collection contains the following
259
268
documents:
@@ -268,10 +277,10 @@ collection of three documents, it matches documents based on the lexical value
268
277
of the strings ("``16``", "``84``", and "``179``"), and deletes the first
269
278
document it finds that matches the query criteria.
270
279
271
- .. literalinclude:: /code-snippets/collation/findOneAndDelete-collation.js
280
+ .. literalinclude:: /code-snippets/collation/findOneAndDelete-no- collation.js
272
281
:language: javascript
273
- :start-after: start findOneAndDelete example without collation
274
- :end-before: end findOneAndDelete example without collation
282
+ :start-after: start findOneAndDelete no collation
283
+ :end-before: end findOneAndDelete no collation
275
284
276
285
Since all the documents contain lexical values in the ``a`` field that
277
286
match the criteria (greater than the lexical value of "``100``"), the operation
@@ -301,3 +310,5 @@ the German phonebook (``de@collation=phonebook`` locale) order.
301
310
302
311
.. literalinclude:: /code-snippets/collation/aggregation-collation.js
303
312
:language: javascript
313
+ :start-after: start aggregation collation
314
+ :end-before: end aggregation collation
0 commit comments