@@ -120,23 +120,26 @@ collection.
120
120
121
121
.. literalinclude:: /code-snippets/collation/collection-collation.js
122
122
:language: javascript
123
- :lineno-start: 2
123
+ :start-after: start collection collation
124
+ :end-before: end collection collation
124
125
125
126
Any of the operations that support collations automatically apply the collation
126
127
defined on the collection. The query below searches the ``souvenirs``
127
128
collection and applies the "``fr_CA``" locale collation:
128
129
129
130
.. literalinclude:: /code-snippets/collation/collection-auto-collation.js
130
131
:language: javascript
131
- :lineno-start: 2
132
+ :start-after: start auto collation
133
+ :end-before: end auto collation
132
134
133
135
You can specify a different collation as a parameter in an operation that
134
136
supports collations. The following query specifies the "``is``" Iceland locale
135
137
and ``caseFirst`` optional parameter with the value "``upper``":
136
138
137
139
.. literalinclude:: /code-snippets/collation/collection-specify-collation.js
138
140
:language: javascript
139
- :lineno-start: 5
141
+ :start-after: start specified collation
142
+ :end-before: end specified collation
140
143
141
144
Assign a Collation to an Index
142
145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -146,25 +149,29 @@ a collection with a collation set to the "``en_US``" locale.
146
149
147
150
.. literalinclude:: /code-snippets/collation/index-collation.js
148
151
:language: javascript
149
- :lineno-start: 5
152
+ :start-after: start create index collation
153
+ :end-before: end create index collation
150
154
151
155
The following query uses the index we created:
152
156
153
157
.. literalinclude:: /code-snippets/collation/query-index-collation.js
154
158
:language: javascript
155
- :lineno-start: 6
159
+ :start-after: start query index collation
160
+ :end-before: end query index collation
156
161
157
162
The following queries **do not** use the index that we created. The first
158
163
query does not include a collation and the second contains a different
159
164
strength value than the collation on the index.
160
165
161
- .. literalinclude:: /code-snippets/collation/query-index- not-indexed-collation.js
166
+ .. literalinclude:: /code-snippets/collation/query-not-indexed-collation.js
162
167
:language: javascript
163
- :lineno-start: 6
168
+ :start-after: start not indexed collation
169
+ :end-before: end not indexed collation
164
170
165
171
.. literalinclude:: /code-snippets/collation/query-index-no-collation.js
166
172
:language: javascript
167
- :lineno-start: 6
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
``````````````````````````
@@ -203,7 +212,8 @@ which **does not** specify a collation:
203
212
204
213
.. literalinclude:: /code-snippets/collation/findOneAndUpdate-default-order-collation.js
205
214
:language: javascript
206
- :lineno-start: 6
215
+ :start-after: start findOneAndUpdate default order collation
216
+ :end-before: end findOneAndUpdate default order collation
207
217
208
218
Since "Gunter" is the first sorted result when using a binary collation, none
209
219
of the documents come lexically before and match the ``$lt`` comparison
@@ -219,7 +229,8 @@ umlauts.
219
229
220
230
.. literalinclude:: /code-snippets/collation/findOneAndUpdate-collation.js
221
231
:language: javascript
222
- :lineno-start: 6
232
+ :start-after: start findOneAndUpdate collation
233
+ :end-before: end findOneAndUpdate collation
223
234
224
235
Since "Günter" lexically comes before "Gunter" using the
225
236
``de@collation=phonebook`` collation specified in ``findOneAndUpdate()``,
@@ -250,10 +261,8 @@ lexical order.
250
261
251
262
.. literalinclude:: /code-snippets/collation/findOneAndDelete-collation.js
252
263
:language: javascript
253
- :lineno-start: 6
254
-
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:
@@ -270,7 +279,8 @@ document it finds that matches the query criteria.
270
279
271
280
.. literalinclude:: /code-snippets/collation/findOneAndDelete-no-collation.js
272
281
:language: javascript
273
- :lineno-start: 6
282
+ :start-after: start findOneAndDelete no collation
283
+ :end-before: end findOneAndDelete no collation
274
284
275
285
Since all the documents contain lexical values in the ``a`` field that
276
286
match the criteria (greater than the lexical value of "``100``"), the operation
@@ -300,3 +310,5 @@ the German phonebook (``de@collation=phonebook`` locale) order.
300
310
301
311
.. literalinclude:: /code-snippets/collation/aggregation-collation.js
302
312
:language: javascript
313
+ :start-after: start aggregation collation
314
+ :end-before: end aggregation collation
0 commit comments