Skip to content

Commit 5112443

Browse files
author
Chris Cho
committed
rst fixes
starts-with and ends-before end before rst fixes fix
1 parent 70a922c commit 5112443

11 files changed

+53
-22
lines changed

source/code-snippets/collation/aggregation-collation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
Retrieve the total number of matching names, grouped by the first_name
33
field and sorted by using the German phonebook collation.
44
*/
5+
// start aggregation collation
56
myColl.aggregate(
67
[
78
{ $group: { "_id": "$first_name", "nameCount": { "$sum": 1 } } },
89
{ $sort: { "_id": 1 } },
910
],
1011
{ collation: { locale: "de@collation=phonebook" } },
1112
);
13+
// end aggregation collation
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
// Retrieve documents that match "photograph" in the "type" field
2-
myColl.find({type: "photograph"});
2+
// start auto collation
3+
myColl.find({type: "photograph"});
4+
// end auto collation
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Create the "souvenirs" collection and specify the French Canadian collation
2+
// start collection collation
23
db.createCollection("souvenirs", {
34
collation: { locale: "fr_CA" },
4-
});
5+
});
6+
// end collection collation

source/code-snippets/collation/collection-specify-collation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Retrieve documents that match "photograph" in the "type" field,
33
sorted by the Iceland collation and uppercase precedence.
44
*/
5+
// start specified collation
56
myColl.find({type: "photograph"},
67
{ collation: { locale: "is", caseFirst: "upper" } }
78
);
8-
9+
// end specified collation

source/code-snippets/collation/find-sort-collation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
Retrieve documents that match "New York" in the "city" field,
33
sorted by the "name" field by using the German collation.
44
*/
5+
// start find sort collation
56
myColl.find({ city: "New York" }, { collation: { locale: "de" } })
67
.sort({ name: 1 });
8+
// end find sort collation

source/code-snippets/collation/findOneAndUpdate-collation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
that precedes "Gunter" when ordered by using the
44
German phonebook collation order.
55
*/
6+
// start findOneAndUpdate collation
67
myColl.findOneAndUpdate(
78
{ first_name: { $lt: "Gunter" } },
89
{ $set: { verified: true } },
910
{ collation: { locale: "de@collation=phonebook" } },
10-
);
11+
);
12+
// end findOneAndUpdate collation

source/code-snippets/collation/index-collation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
locale collation, specifying ascending ordering of the
44
"title" field.
55
*/
6+
// start create index collation
67
myColl.createIndex(
78
{ 'title' : 1 },
89
{ 'collation' : { 'locale' : 'en_US' } });
10+
// end create index collation

source/code-snippets/collation/query-index-collation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
in descending order of the value of the "title" field,
44
specifying a collation that uses the index.
55
*/
6+
// start query index collation
67
myColl.find({"year": 1980}, {"collation" : {"locale" : "en_US" }})
7-
.sort({"title": -1});
8+
.sort({"title": -1});
9+
// end query index collation

source/code-snippets/collation/query-index-no-collation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Retrieve documents that match the "year" value "1980"
33
in descending order of the value of the "title" field
44
that does not use the collation index.
5-
*/
5+
*/
6+
// start index no collation
67
myColl.find({"year": 1980})
78
.sort({"title": -1});
9+
// end index no collation

source/code-snippets/collation/query-not-indexed-collation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
specifying a collation that does not use the collation
55
index.
66
*/
7+
// start not indexed collation
78
myColl.find({"year": 1980}, {"collation" : {"locale" : "en_US", "strength": 2 }})
8-
.sort({"title": -1});
9+
.sort({"title": -1});
10+
// end not indexed collation

source/fundamentals/collations.txt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,26 @@ collection.
120120

121121
.. literalinclude:: /code-snippets/collation/collection-collation.js
122122
:language: javascript
123-
:lineno-start: 2
123+
:start-after: start collection collation
124+
:end-before: end collection collation
124125

125126
Any of the operations that support collations automatically apply the collation
126127
defined on the collection. The query below searches the ``souvenirs``
127128
collection and applies the "``fr_CA``" locale collation:
128129

129130
.. literalinclude:: /code-snippets/collation/collection-auto-collation.js
130131
:language: javascript
131-
:lineno-start: 2
132+
:start-after: start auto collation
133+
:end-before: end auto collation
132134

133135
You can specify a different collation as a parameter in an operation that
134136
supports collations. The following query specifies the "``is``" Iceland locale
135137
and ``caseFirst`` optional parameter with the value "``upper``":
136138

137139
.. literalinclude:: /code-snippets/collation/collection-specify-collation.js
138140
:language: javascript
139-
:lineno-start: 5
141+
:start-after: start specified collation
142+
:end-before: end specified collation
140143

141144
Assign a Collation to an Index
142145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -146,25 +149,29 @@ a collection with a collation set to the "``en_US``" locale.
146149

147150
.. literalinclude:: /code-snippets/collation/index-collation.js
148151
:language: javascript
149-
:lineno-start: 5
152+
:start-after: start create index collation
153+
:end-before: end create index collation
150154

151155
The following query uses the index we created:
152156

153157
.. literalinclude:: /code-snippets/collation/query-index-collation.js
154158
:language: javascript
155-
:lineno-start: 6
159+
:start-after: start query index collation
160+
:end-before: end query index collation
156161

157162
The following queries **do not** use the index that we created. The first
158163
query does not include a collation and the second contains a different
159164
strength value than the collation on the index.
160165

161-
.. literalinclude:: /code-snippets/collation/query-index-not-indexed-collation.js
166+
.. literalinclude:: /code-snippets/collation/query-not-indexed-collation.js
162167
:language: javascript
163-
:lineno-start: 6
168+
:start-after: start not indexed collation
169+
:end-before: end not indexed collation
164170

165171
.. literalinclude:: /code-snippets/collation/query-index-no-collation.js
166172
:language: javascript
167-
:lineno-start: 6
173+
:start-after: start index no collation
174+
:end-before: end index no collation
168175

169176
Collation Query Examples
170177
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -183,6 +190,8 @@ setting the value of the ``locale`` parameter to ``de``.
183190

184191
.. literalinclude:: /code-snippets/collation/find-sort-collation.js
185192
:language: javascript
193+
:start-after: start find sort collation
194+
:end-before: end find sort collation
186195

187196
findOneAndUpdate() Example
188197
``````````````````````````
@@ -203,7 +212,8 @@ which **does not** specify a collation:
203212

204213
.. literalinclude:: /code-snippets/collation/findOneAndUpdate-default-order-collation.js
205214
:language: javascript
206-
:lineno-start: 6
215+
:start-after: start findOneAndUpdate default order collation
216+
:end-before: end findOneAndUpdate default order collation
207217

208218
Since "Gunter" is the first sorted result when using a binary collation, none
209219
of the documents come lexically before and match the ``$lt`` comparison
@@ -219,7 +229,8 @@ umlauts.
219229

220230
.. literalinclude:: /code-snippets/collation/findOneAndUpdate-collation.js
221231
:language: javascript
222-
:lineno-start: 6
232+
:start-after: start findOneAndUpdate collation
233+
:end-before: end findOneAndUpdate collation
223234

224235
Since "Günter" lexically comes before "Gunter" using the
225236
``de@collation=phonebook`` collation specified in ``findOneAndUpdate()``,
@@ -250,10 +261,8 @@ lexical order.
250261

251262
.. literalinclude:: /code-snippets/collation/findOneAndDelete-collation.js
252263
: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
257266

258267
After you run the operation above, the collection contains the following
259268
documents:
@@ -270,7 +279,8 @@ document it finds that matches the query criteria.
270279

271280
.. literalinclude:: /code-snippets/collation/findOneAndDelete-no-collation.js
272281
:language: javascript
273-
:lineno-start: 6
282+
:start-after: start findOneAndDelete no collation
283+
:end-before: end findOneAndDelete no collation
274284

275285
Since all the documents contain lexical values in the ``a`` field that
276286
match the criteria (greater than the lexical value of "``100``"), the operation
@@ -300,3 +310,5 @@ the German phonebook (``de@collation=phonebook`` locale) order.
300310

301311
.. literalinclude:: /code-snippets/collation/aggregation-collation.js
302312
:language: javascript
313+
:start-after: start aggregation collation
314+
:end-before: end aggregation collation

0 commit comments

Comments
 (0)