Skip to content

Commit e9ea564

Browse files
authored
DOCSP-30536: Retrieve guide tech review (#37)
1 parent 24310fa commit e9ea564

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

source/fundamentals/crud/read-operations/retrieve.txt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ Find Operations
6464
Use **find operations** to retrieve data from MongoDB. Find operations
6565
consist of the ``find()`` and ``find_one()`` methods.
6666

67+
You can also run find operations after starting a session with the
68+
``find_with_session()`` and ``find_one_with_session()`` methods. Both methods
69+
take an additional ``ClientSession`` parameter, or a logical session used for
70+
ordering sequential operations. To learn more about these two methods, see the
71+
API documentation for `find_with_session() <{+api+}/struct.Collection.html#method.find_with_session>`__
72+
and `find_one_with_session() <{+api+}/struct.Collection.html#method.find_one_with_session>`__.
73+
6774
Find All Matching Documents
6875
~~~~~~~~~~~~~~~~~~~~~~~~~~~
6976

@@ -89,8 +96,10 @@ To find *the first document* that matches your criteria, use the
8996
query filter consists of the fields and values that form criteria for
9097
documents to match.
9198

92-
If a document matches the filter criteria, the method returns a ``Some``
93-
type. If it does not match any documents, it returns a ``None`` type.
99+
If a document matches the filter criteria, the method returns a
100+
``Result<Option<T>>`` type with a value of ``Some``. If no documents
101+
match the filter criteria, ``find_one()`` returns a ``Result<Option<T>>``
102+
type with a value of ``None``.
94103

95104
To see an example that uses this method to retrieve data, see
96105
the :ref:`find_one() example <rust-find-one-example>`.
@@ -119,17 +128,17 @@ The following table describes commonly used settings that you can specify in
119128

120129
* - ``collation``
121130
- | The collation to use when sorting results.
122-
| Default: ``nil``
131+
| Default: ``None``
123132

124133
* - ``hint``
125134
- | The index to use for the operation. To learn more about
126135
indexes, see :manual:`Indexes </indexes/>` in the Server
127136
manual.
128-
| Default: ``nil``
137+
| Default: ``None``
129138

130139
* - ``projection``
131140
- | The projection to use when returning results.
132-
| Default: ``nil``
141+
| Default: ``None``
133142

134143
* - ``read_concern``
135144
- | The read concern to use for the find operation. If you don't
@@ -140,14 +149,14 @@ The following table describes commonly used settings that you can specify in
140149

141150
* - ``skip``
142151
- | The number of documents to skip when returning results.
143-
| Default: ``nil``
152+
| Default: ``None``
144153

145154
* - ``sort``
146155
- | The sort to use when returning results. By default, the driver
147156
returns documents in their natural order, or as they appear in
148157
the database. To learn more, see :manual:`natural order </reference/glossary/#std-term-natural-order>`
149158
in the Server manual glossary.
150-
| Default: ``nil``
159+
| Default: ``None``
151160

152161
.. TODO link to projection fundamentals page under projection setting
153162
.. TODO link to collation fundamentals page under collations setting
@@ -301,13 +310,13 @@ The following table describes commonly used settings that you can specify in
301310

302311
* - ``collation``
303312
- | The collation to use when sorting results.
304-
| Default: ``nil``
313+
| Default: ``None``
305314

306315
* - ``hint``
307316
- | The index to use for the operation. To learn more about
308317
indexes, see :manual:`Indexes </indexes/>` in the Server
309318
manual.
310-
| Default: ``nil``
319+
| Default: ``None``
311320

312321
* - ``read_concern``
313322
- | The read concern to use for the find operation. If you don't

source/includes/fundamentals/code-snippets/crud/retrieve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn main() -> mongodb::error::Result<()> {
2020
my_coll.insert_many(docs, None).await?;
2121

2222
// begin-find-many
23-
let opts: FindOptions = FindOptions::builder()
23+
let opts = FindOptions::builder()
2424
.sort(doc! { "unit_price": -1 })
2525
.build();
2626

@@ -41,7 +41,7 @@ async fn main() -> mongodb::error::Result<()> {
4141
print!("\n");
4242

4343
// begin-find-one
44-
let opts: FindOneOptions = FindOneOptions::builder().skip(2).build();
44+
let opts = FindOneOptions::builder().skip(2).build();
4545
let result = my_coll.find_one(
4646
doc! { "unit_price":
4747
doc! { "$lte": 20.00 } },

0 commit comments

Comments
 (0)