@@ -101,58 +101,25 @@ Find Multiple Documents Example: Full File
101
101
102
102
The following example finds all documents in the ``restaurants`` collection
103
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
- Select the :guilabel:`Struct` or :guilabel:`bson.D` tab to see the corresponding code:
104
+ references the matched documents and unpacks the documents into a slice:
106
105
107
- .. tabs::
108
-
109
- .. tab :: Struct
110
- :tabid: structExample
111
-
112
- The following code uses structs to find and return all documents in the
113
- ``restaurants`` collection in which the value of ``cuisine`` is "Italian":
114
-
115
- .. io-code-block::
116
- :copyable: true
117
-
118
- .. input:: /includes/usage-examples/code-snippets/find.go
119
- :language: go
120
- :dedent:
121
-
122
- .. output::
123
- :language: none
124
- :visible: false
125
-
126
- // results truncated
127
- ...
128
- { ... , "Name" : "Epistrophy Cafe", "RestaurantId": "41117553", "Cuisine" : "Italian", ... },
129
- { ... , "Name" : "Remi", "RestaurantId": "41118090", "Cuisine" : "Italian", ... },
130
- { ... , "Name" : "Sant Ambroeus", "RestaurantId": "41120682", "Cuisine" : "Italian", ... },
131
- ...
132
-
133
- .. tab :: bson.D
134
- :tabid: bsonDExample
135
-
136
- The following code uses a bson.D type to find and return all documents in
137
- the ``restaurants`` collection in which the value of ``cuisine`` is "Italian":
138
-
139
- .. io-code-block::
140
- :copyable: true
106
+ .. io-code-block::
107
+ :copyable: true
141
108
142
- .. input:: /includes/usage-examples/code-snippets/findBsonD .go
143
- :language: go
144
- :dedent:
109
+ .. input:: /includes/usage-examples/code-snippets/find .go
110
+ :language: go
111
+ :dedent:
145
112
146
- .. output::
147
- :language: none
148
- :visible: false
113
+ .. output::
114
+ :language: none
115
+ :visible: false
149
116
150
- // results truncated
151
- ...
152
- { ... , "Name" : "Epistrophy Cafe", "RestaurantId": "41117553", "Cuisine" : "Italian", ... },
153
- { ... , "Name" : "Remi", "RestaurantId": "41118090", "Cuisine" : "Italian", ... },
154
- { ... , "Name" : "Sant Ambroeus", "RestaurantId": "41120682", "Cuisine" : "Italian", ... },
155
- ...
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
+ ...
156
123
157
124
.. _golang-find-one-example:
158
125
@@ -247,67 +214,30 @@ Find One Document Example: Full File
247
214
248
215
.. include:: /includes/usage-examples/example-intro.rst
249
216
250
- The following example finds a document in the ``restaurants`` collection that
251
- matches a query filter. Select the :guilabel:`Struct` or :guilabel:`bson.D`
252
- tab to see the corresponding code:
253
-
254
- .. tabs::
255
-
256
- .. tab :: Struct
257
- :tabid: structExample
258
-
259
- The following code uses structs to find and return the first document in the
260
- ``restaurants`` collection in which the value of ``name`` is "Bagels N Buns":
261
-
262
- .. io-code-block::
263
- :copyable: true
264
-
265
- .. input:: /includes/usage-examples/code-snippets/findOne.go
266
- :language: go
267
- :dedent:
268
-
269
- .. output::
270
- :language: none
271
- :visible: false
272
-
273
- // results truncated
274
- {
275
- "ID": "5eb3d668b31de5d588f42950",
276
- "Name": "Bagels N Buns",
277
- "RestaurantId": "40363427"
278
- "Address": [...],
279
- "Borough": "Staten Island",
280
- "Cuisine": "Delicatessen",
281
- "Grades": [...]
282
- }
283
-
284
- .. tab :: bson.D
285
- :tabid: bsonDExample
286
-
287
- The following code uses a bson.D type to find and return the first document
288
- in the ``restaurants`` collection in which the value of ``name`` is "Bagels N Buns":
289
-
290
- .. io-code-block::
291
- :copyable: true
292
-
293
- .. input:: /includes/usage-examples/code-snippets/findOneBsonD.go
294
- :language: go
295
- :dedent:
296
-
297
- .. output::
298
- :language: none
299
- :visible: false
300
-
301
- // results truncated
302
- {
303
- "ID": "5eb3d668b31de5d588f42950",
304
- "Name": "Bagels N Buns",
305
- "RestaurantId": "40363427"
306
- "Address": [...],
307
- "Borough": "Staten Island",
308
- "Cuisine": "Delicatessen",
309
- "Grades": [...]
310
- }
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
+ }
311
241
312
242
.. _golang-retrieve-options:
313
243
0 commit comments