Skip to content

Commit 229473f

Browse files
committed
NR feedback
1 parent 80c94ba commit 229473f

File tree

9 files changed

+84
-61
lines changed

9 files changed

+84
-61
lines changed

source/crud/read-operations/retrieve.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Retrieve Data
1515
.. contents:: On this page
1616
:local:
1717
:backlinks: none
18-
:depth: 1
18+
:depth: 2
1919
:class: singlecol
2020

2121
Overview
@@ -63,7 +63,8 @@ specify a query, see our :ref:`Specify a Query
6363
<java-query>` guide.
6464

6565
To retrieve a single document, you can append the ``first()`` method to your
66-
``find()`` operation.
66+
``find()`` operation. You can use the ``sort()`` operation before selecting the first
67+
document to help choose the correct file.
6768

6869
Example
6970
~~~~~~~
@@ -96,12 +97,14 @@ criteria.
9697
Find Example: Full File
9798
~~~~~~~~~~~~~~~~~~~~~~~
9899

99-
The following code is a complete, standalone file that performs a find
100-
operation to retrieve multiple douments, and a find operation with the first
101-
method to retrieve a single document.
102-
103100
.. include:: /includes/crud/example-intro.rst
104101

102+
The following code is a complete, standalone file that performs the following
103+
actions:
104+
105+
- Calls the ``find()`` method to retrieve multiple documents that have a ``runtime`` value less than 15, applying a projection and sort to the results
106+
- Calls the ``find()`` and ``first()`` method to retrieve a document that has a ``title`` value of ``"The Room"``, applying a projection and sort before returning the first match
107+
105108
.. io-code-block::
106109

107110
.. input:: /includes/crud/Find.java
@@ -114,7 +117,7 @@ method to retrieve a single document.
114117

115118
Number of documents found with find(): 101
116119

117-
Document found with find().first(){"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
120+
Document found with find().first(): {"title": "The Room", "imdb": {"rating": 3.5, "votes": 25673, "id": 368226}}
118121

119122
.. _retrieve-aggregate:
120123

@@ -166,19 +169,22 @@ purchased color.
166169
For more information about how to construct an aggregation pipeline, see
167170
the {+mdb-server+} manual page on :manual:`Aggregation </aggregation>`.
168171

172+
Additional Information
173+
----------------------
174+
169175
API Documentation
170-
-----------------
176+
~~~~~~~~~~~~~~~~~
171177

172-
For more information on the methods and classes used to retrieve documents
173-
on this page, see the following API Documentation:
178+
For more information about the methods and classes used to retrieve documents
179+
on this page, see the following API cocumentation:
174180

175181
- `find() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#find()>`__
176182
- `first() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoIterable.html#first()>`__
177183
- `FindIterable <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/FindIterable.html>`__
178184
- `aggregate() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#aggregate(java.util.List)>`__
179185

180186
Server Manual Entries
181-
---------------------
187+
~~~~~~~~~~~~~~~~~~~~~
182188

183189
- :manual:`Collections </core/databases-and-collections/#collections>`
184190
- :manual:`Query Documents </tutorial/query-documents>`

source/crud/write-operations/bulk.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,17 @@ see the following API documentation:
360360
- `ordered() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/BulkWriteOptions.html#ordered(boolean)>`__
361361

362362

363-
BulkWrite Example: Full File
364-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365-
366-
The following code is a complete, standalone file that performs an ordered bulk
367-
write operation.
363+
Bulk Write Example: Full File
364+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368365

369366
.. include:: /includes/crud/example-intro.rst
370367

371-
This example call to ``bulkWrite()`` includes examples of the ``InsertOneModel``,
372-
``UpdateOneModel``, ``DeleteOneModel``, and ``ReplaceOneModel``.
368+
The following code is a complete, standalone file that performs the following
369+
actions:
370+
371+
#. Creates a list of instances of the ``InsertOneModel``, ``UpdateOneModel``,
372+
``DeleteOneModel``, and ``ReplaceOneModel`` classes.
373+
#. Runs an ordered ``bulkWrite()`` operation on the list.
373374

374375
.. io-code-block::
375376

@@ -622,28 +623,31 @@ Even though the write operation inserting a document with a duplicate key result
622623
in an error, the other operations are executed because the write operation is
623624
unordered.
624625

626+
Additional Information
627+
----------------------
628+
625629
API Documentation
626-
-----------------
630+
~~~~~~~~~~~~~~~~~
627631

628632
To learn more about the methods and classes used to perform bulk write
629633
operations in this section, see the following API documentation:
630634

631635
MongoCollection
632-
~~~~~~~~~~~~~~~
636+
```````````````
633637

634638
- `bulkWrite() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#bulkWrite(com.mongodb.client.ClientSession,java.util.List)>`__
635639
- `BulkWriteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/BulkWriteOptions.html>`__
636640
- `MongoBulkWriteException <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoBulkWriteException.html>`__
637641

638642
MongoClient
639-
~~~~~~~~~~~
643+
````````````
640644

641645
- `bulkWrite() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCluster.html#bulkWrite(com.mongodb.client.ClientSession,java.util.List)>`__
642646
- `ClientBulkWriteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/bulk/ClientBulkWriteOptions.html>`__
643647
- `ClientBulkWriteResult <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/bulk/ClientBulkWriteResult.html>`__
644648

645649
Server Manual Entries
646-
---------------------
650+
~~~~~~~~~~~~~~~~~~~~~
647651

648652
- :manual:`MongoCollection.bulkWrite() </reference/method/db.collection.bulkWrite/>`
649653
- :manual:`MongoClient.bulkWrite() </reference/command/bulkWrite/>`

source/crud/write-operations/delete.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,10 @@ collection:
151151
Delete Example: Full File
152152
-------------------------
153153

154-
The following code is a complete, standalone file that performs a delete one
155-
operation and a delete many operation.
156-
157154
.. include:: /includes/crud/example-intro.rst
158155

159-
The query uses the ``eq()`` and ``lt()`` filters to query documents. For more
160-
information about filters, see the `Filters Class
161-
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Filters.html>`__
162-
API documentation.
156+
The following code is a complete, standalone file that performs a delete one
157+
operation and a delete many operation.
163158

164159
.. io-code-block::
165160

@@ -174,10 +169,19 @@ API documentation.
174169
DeleteOne document count: 1
175170
DeleteMany document count: 4
176171

172+
173+
The query in this examples uses the ``eq()`` and ``lt()`` filters to query documents. For more
174+
information about filters, see the `Filters Class
175+
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Filters.html>`__
176+
API documentation.
177+
178+
Additional Information
179+
----------------------
180+
177181
API Documentation
178-
-----------------
182+
~~~~~~~~~~~~~~~~~
179183

180-
For more information on the methods and classes used to delete documents, see the following API Documentation:
184+
For more information about the methods and classes used to delete documents, see the following API cocumentation:
181185

182186
- `deleteOne() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteOne(org.bson.conversions.Bson)>`__
183187
- `deleteMany() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteMany(org.bson.conversions.Bson)>`__
@@ -187,7 +191,7 @@ For more information on the methods and classes used to delete documents, see th
187191
- `DeleteResult <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/result/DeleteResult.html>`__
188192

189193
Server Manual Entries
190-
---------------------
194+
~~~~~~~~~~~~~~~~~~~~~
191195

192196
- :manual:`db.collection.deleteOne() </reference/method/db.collection.deleteOne/>`
193197
- :manual:`db.collection.deleteMany() </reference/method/db.collection.deleteMany/>`

source/crud/write-operations/insert.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ The following sections focus on ``insertOne()`` and
3030
method, see our
3131
:ref:`guide on Bulk Operations <java-fundamentals-bulkwrite>`.
3232

33-
.. note:: The ``id_`` field in Insert Operations
33+
.. note:: The ``id_`` Field in Insert Operations
3434

3535
When inserting a document, MongoDB enforces one constraint on your
36-
documents by default: each document *must* contain a unique ``_id``
37-
field. Duplicate ``_id`` values violate unique index constraints, resulting in a ``WriteError``.
36+
documents by default: each document *must* contain a unique ``_id`` value.
37+
Duplicate ``_id`` values violate unique index constraints, resulting in a
38+
``WriteError``.
3839

3940
There are two ways to manage this field:
4041

@@ -44,7 +45,7 @@ method, see our
4445
Unless you have provided strong guarantees for uniqueness, we recommend
4546
you let the driver automatically generate ``_id`` values.
4647

47-
For more information on unique indexes, see the manual entry on
48+
For more information about unique indexes, see the manual entry on
4849
:manual:`Unique Indexes </core/index-unique/>`.
4950

5051
.. _java-insertone:
@@ -160,11 +161,11 @@ The output of the preceding code resembles the following:
160161
Insert Example: Full File
161162
-------------------------
162163

164+
.. include:: /includes/crud/example-intro.rst
165+
163166
The following code is a complete, standalone file that performs an insert one
164167
operation and an insert many operation.
165168

166-
.. include:: /includes/crud/example-intro.rst
167-
168169
.. io-code-block::
169170

170171
.. input:: /includes/crud/Insert.java
@@ -178,18 +179,21 @@ operation and an insert many operation.
178179
InsertOne document id: BsonObjectId{value=...}
179180
InsertMany document ids: {0=BsonObjectId{value=...}, 1=BsonObjectId{value=...}}
180181

182+
Additional Information
183+
----------------------
184+
181185
API Documentation
182-
-----------------
186+
~~~~~~~~~~~~~~~~~
183187

184-
For more information on the methods and classes used to insert documents, see the following API Documentation:
188+
For more information about the methods and classes used to insert documents, see the following API cocumentation:
185189

186190
- `insertOne() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#insertOne(TDocument)>`__
187191
- `InsertOneResult <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/result/InsertOneResult.html>`__
188192
- `insertMany() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#insertMany(java.util.List)>`__
189193
- `InsertManyResult <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/result/InsertManyResult.html>`__
190194

191195
Server Manual Entries
192-
---------------------
196+
~~~~~~~~~~~~~~~~~~~~~
193197

194198
- :manual:`db.collection.insertOne() </reference/method/db.collection.insertOne/>`
195199
- :manual:`db.collection.insertMany() </reference/method/db.collection.insertMany/>`

source/crud/write-operations/modify.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ documents match.
283283
ReplaceOne Example: Full File
284284
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285285

286-
The following code is a complete, standalone file that performs a replace one operation.
287-
288286
.. include:: /includes/crud/example-intro.rst
289287

288+
The following code is a complete, standalone file that performs a replace one operation.
289+
290290
.. io-code-block::
291291

292292
.. input:: /includes/crud/ReplaceOne.java
@@ -302,10 +302,13 @@ The following code is a complete, standalone file that performs a replace one op
302302

303303
UpdateMany modified document count: 242
304304

305+
Additional Information
306+
----------------------
307+
305308
API Documentation
306-
-----------------
309+
~~~~~~~~~~~~~~~~~
307310

308-
For more information on the methods and classes used to modify documents, see the following API Documentation:
311+
For more information about the methods and classes used to modify documents, see the following API cocumentation:
309312

310313
- `updateOne() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#updateOne(org.bson.conversions.Bson,java.util.List,com.mongodb.client.model.UpdateOptions)>`__
311314
- `updateMany() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#updateMany(org.bson.conversions.Bson,java.util.List,com.mongodb.client.model.UpdateOptions)>`__
@@ -314,8 +317,8 @@ For more information on the methods and classes used to modify documents, see th
314317
- `ReplaceOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOptions.html?is-external=true>`__
315318
- `UpdateResult <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/result/UpdateResult.html>`__
316319

317-
For more information on the methods used in the examples on this
318-
page, see the following API Documentation:
320+
For more information about the methods used in the examples on this
321+
page, see the following API cocumentation:
319322

320323
- `eq() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Filters.html#eq(java.lang.String,TItem)>`__
321324
- `combine() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Updates.html#combine(org.bson.conversions.Bson...)>`__
@@ -324,7 +327,7 @@ page, see the following API Documentation:
324327
- `currentTimestamp() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Updates.html#currentTimestamp(java.lang.String)>`__
325328

326329
Server Manual Entries
327-
---------------------
330+
~~~~~~~~~~~~~~~~~~~~~
328331

329332
- :manual:`db.collection.updateOne() </reference/method/db.collection.updateOne/>`
330333
- :manual:`db.collection.updateMany() </reference/method/db.collection.updateMany/>`

source/includes/crud/Delete.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void main(String[] args) {
3232
try {
3333
// Deletes the first document that has a "title" value of "The Garbage Pail Kids Movie"
3434
DeleteResult result = collection.deleteOne(deleteOneQuery);
35-
System.out.println("DeleteOne document count: " + result.getDeletedCount());
35+
System.out.println("deleteOne() document count: " + result.getDeletedCount());
3636

3737
// Prints a message if any exceptions occur during the operation
3838
} catch (MongoException me) {
@@ -46,7 +46,7 @@ public static void main(String[] args) {
4646
DeleteResult result = collection.deleteMany(deleteManyQuery);
4747

4848
// Prints the number of deleted documents
49-
System.out.println("DeleteMany document count: " + result.getDeletedCount());
49+
System.out.println("deleteMany() document count: " + result.getDeletedCount());
5050

5151
// Prints a message if any exceptions occur during the operation
5252
} catch (MongoException me) {

source/includes/crud/Find.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void main( String[] args ) {
4848
if (doc == null) {
4949
System.out.println("No results found.");
5050
} else {
51-
System.out.println("Document found with find().first()" + doc.toJson());
51+
System.out.println("Document found with find().first(): " + doc.toJson());
5252
}
5353
}
5454
}

source/includes/crud/Insert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void main(String[] args) {
3434
.append("genres", Arrays.asList("Documentary", "Comedy")));
3535

3636
// Prints the ID of the inserted document
37-
System.out.println("InsertOne document id: " + result.getInsertedId());
37+
System.out.println("insertOne() document id: " + result.getInsertedId());
3838

3939
// Prints a message if any exceptions occur during the operation
4040
} catch (MongoException me) {
@@ -51,7 +51,7 @@ public static void main(String[] args) {
5151
InsertManyResult result = collection.insertMany(movieList);
5252

5353
// Prints the IDs of the inserted documents
54-
System.out.println("InsertMany document ids: " + result.getInsertedIds());
54+
System.out.println("insertMany() document ids: " + result.getInsertedIds());
5555

5656
// Prints a message if any exceptions occur during the operation
5757
} catch (MongoException me) {
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
This example connects to an instance of MongoDB using a connection URI. To learn
2-
more about connecting to your MongoDB instance, see the :ref:`connection guide
3-
<connect-to-mongodb>`. It also uses the ``movies`` collection in the
4-
``sample_mflix`` database included in the :atlas:`sample datasets
5-
</sample-data?jmp=docs_driver_java>` provided by Atlas. You can load them into
6-
your database on the free tier of MongoDB Atlas by following the :atlas:`Get
7-
Started with Atlas Guide
8-
</getting-started/#atlas-getting-started?jmp=docs_driver_java>`.
1+
.. note:: Example Setup
2+
3+
This example connects to an instance of MongoDB by using a connection URI. To learn
4+
more about connecting to your MongoDB instance, see the :ref:`connection guide
5+
<connect-to-mongodb>`. This example also uses the ``movies`` collection in the
6+
``sample_mflix`` database included in the :atlas:`Atlas sample datasets
7+
</sample-data?jmp=docs_driver_java>`. You can load them into
8+
your database on the free tier of MongoDB Atlas by following the :atlas:`Get
9+
Started with Atlas Guide
10+
</getting-started/#atlas-getting-started?jmp=docs_driver_java>`.

0 commit comments

Comments
 (0)