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:
21
32=====================
43Run a Command Example
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ func main() {
3535 }()
3636
3737 {
38- // begin runCommand
3938 db := client .Database ("sample_restaurants" )
4039
4140 // Retrieves statistics about the specified database
@@ -49,7 +48,6 @@ func main() {
4948 if err != nil {
5049 panic (err )
5150 }
52- // end runCommand
5351
5452 /* When you run this file, it should print something similar to the following:
5553 {
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
168168 }
169169 }
170170
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+
171211.. _addl-info-runcommand:
172212
173213Additional Information
You can’t perform that action at this time.
0 commit comments