@@ -62,8 +62,8 @@ consist of the ``Find()`` and ``FindOne()`` methods.
6262
6363.. _golang-find-example:
6464
65- Find All Documents
66- ~~~~~~~~~~~~~~~~~~
65+ Find Multiple Documents
66+ ~~~~~~~~~~~~~~~~~~~~~~~
6767
6868The ``Find()`` method expects you to pass a ``Context`` type and a
6969query filter. The method returns *all* documents that match the filter
@@ -94,6 +94,33 @@ the ``Find()`` method, which performs the following actions:
9494
9595To learn how to access data by using a cursor, see the :ref:`golang-cursor` guide.
9696
97+ Find Multiple Documents Example: Full File
98+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99+
100+ .. include:: /includes/usage-examples/example-intro.rst
101+
102+ The following example finds all documents in the ``restaurants`` collection
103+ in which the value of ``cuisine`` is ``"Italian"``. The example returns a cursor that
104+ references the matched documents and unpacks the documents into a slice:
105+
106+ .. io-code-block::
107+ :copyable: true
108+
109+ .. input:: /includes/usage-examples/code-snippets/find.go
110+ :language: go
111+ :dedent:
112+
113+ .. output::
114+ :language: none
115+ :visible: false
116+
117+ // results truncated
118+ ...
119+ { ... , "Name" : "Epistrophy Cafe", "RestaurantId": "41117553", "Cuisine" : "Italian", ... },
120+ { ... , "Name" : "Remi", "RestaurantId": "41118090", "Cuisine" : "Italian", ... },
121+ { ... , "Name" : "Sant Ambroeus", "RestaurantId": "41120682", "Cuisine" : "Italian", ... },
122+ ...
123+
97124.. _golang-find-one-example:
98125
99126Find One Document
@@ -182,6 +209,36 @@ as parameters to the ``FindOne()`` method to perform the following actions:
182209 about the ``_id`` field, see the :ref:`_id Field <golang-insert-id>`
183210 section of the Insert a Document page.
184211
212+ Find One Document Example: Full File
213+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214+
215+ .. include:: /includes/usage-examples/example-intro.rst
216+
217+ The following example finds and returns the first document in the
218+ ``restaurants`` collection in which the value of ``name`` is ``"Bagels N Buns"``:
219+
220+ .. io-code-block::
221+ :copyable: true
222+
223+ .. input:: /includes/usage-examples/code-snippets/findOne.go
224+ :language: go
225+ :dedent:
226+
227+ .. output::
228+ :language: none
229+ :visible: false
230+
231+ // results truncated
232+ {
233+ "ID": "5eb3d668b31de5d588f42950",
234+ "Name": "Bagels N Buns",
235+ "RestaurantId": "40363427"
236+ "Address": [...],
237+ "Borough": "Staten Island",
238+ "Cuisine": "Delicatessen",
239+ "Grades": [...]
240+ }
241+
185242.. _golang-retrieve-options:
186243
187244Modify Behavior
@@ -330,20 +387,12 @@ the MongoDB server manual page on :manual:`Aggregation
330387Additional Information
331388----------------------
332389
333- For runnable examples of the find operations, see the following usage
334- examples:
335-
336- - :ref:`golang-find-one`
337- - :ref:`golang-find-multiple`
338-
339390To learn more about the operations mentioned, see the following
340391guides:
341392
342393- :ref:`golang-query-document`
343394- :ref:`golang-cursor`
344- - :ref:`golang-skip`
345- - :ref:`golang-sort-results`
346- - :ref:`golang-limit`
395+ - :ref:`Specify Documents to Return <golang-specify-documents-to-return>`
347396- :ref:`golang-project`
348397- :ref:`golang-aggregation`
349398- :ref:`golang-collations`
0 commit comments