Skip to content

Commit 2558161

Browse files
lindseymoorerachel-mack
authored andcommitted
DOCSP-51824 Standardize Run a Command usage ex (mongodb#545)
1 parent c0c7413 commit 2558161

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

source/archive-reference-files/usage-examples/command.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.. _golang-run-command-usage-example:
21

32
=====================
43
Run a Command Example

source/includes/usage-examples/code-snippets/command.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff 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
{

source/run-command.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff 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

173213
Additional Information

0 commit comments

Comments
 (0)