File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed
archive-reference-files/usage-examples
includes/usage-examples/code-snippets Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 1
- .. _golang-run-command-usage-example:
2
1
3
2
=====================
4
3
Run a Command Example
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ func main() {
35
35
}()
36
36
37
37
{
38
- // begin runCommand
39
38
db := client .Database ("sample_restaurants" )
40
39
41
40
// Retrieves statistics about the specified database
@@ -49,7 +48,6 @@ func main() {
49
48
if err != nil {
50
49
panic (err )
51
50
}
52
- // end runCommand
53
51
54
52
/* When you run this file, it should print something similar to the following:
55
53
{
Original file line number Diff line number Diff line change @@ -168,6 +168,46 @@ plans. The output also contains information about the execution of the
168
168
}
169
169
}
170
170
171
+ .. _golang-run-command-usage-example:
172
+
173
+ Run a Command Example: Full File
174
+ --------------------------------
175
+
176
+ .. note:: Example Setup
177
+
178
+ This example connects to an instance of MongoDB by using a
179
+ connection URI. To learn more about connecting to your MongoDB
180
+ instance, see the :ref:`golang-mongoclient` guide. This example
181
+ also uses the ``sample_restaurants`` database
182
+ included in the :atlas:`Atlas sample datasets </sample-data>`. You
183
+ can load them into your database on the free tier of MongoDB Atlas
184
+ by following the :atlas:`Get Started with Atlas Guide
185
+ </getting-started/#atlas-getting-started>`.
186
+
187
+ The following example retrieves statistics about the
188
+ ``sample_restaurants`` database:
189
+
190
+ .. io-code-block::
191
+ :copyable: true
192
+
193
+ .. input:: /includes/usage-examples/code-snippets/command.go
194
+ :language: go
195
+ :dedent:
196
+
197
+ .. output::
198
+ :language: none
199
+ :visible: false
200
+
201
+ // results truncated
202
+ {
203
+ "avgObjSize": 548.4101901854896,
204
+ "collections": 2,
205
+ "dataSize": 14014074,
206
+ "db": "sample_restaurants",
207
+ "indexSize": 286720,
208
+ ...,
209
+ }
210
+
171
211
.. _addl-info-runcommand:
172
212
173
213
Additional Information
You can’t perform that action at this time.
0 commit comments