Skip to content

DOCSP-51824 Standardize Run a Command usage ex #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion source/archive-reference-files/usage-examples/command.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.. _golang-run-command-usage-example:

=====================
Run a Command Example
Expand Down
2 changes: 0 additions & 2 deletions source/includes/usage-examples/code-snippets/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func main() {
}()

{
// begin runCommand
db := client.Database("sample_restaurants")

// Retrieves statistics about the specified database
Expand All @@ -49,7 +48,6 @@ func main() {
if err != nil {
panic(err)
}
// end runCommand

/* When you run this file, it should print something similar to the following:
{
Expand Down
40 changes: 40 additions & 0 deletions source/run-command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,46 @@ plans. The output also contains information about the execution of the
}
}

.. _golang-run-command-usage-example:

Run a Command Example: Full File
--------------------------------

.. note:: Example Setup

This example connects to an instance of MongoDB by using a
connection URI. To learn more about connecting to your MongoDB
instance, see the :ref:`golang-mongoclient` guide. This example
also uses the ``sample_restaurants`` database
included in the :atlas:`Atlas sample datasets </sample-data>`. You
can load them into your database on the free tier of MongoDB Atlas
by following the :atlas:`Get Started with Atlas Guide
</getting-started/#atlas-getting-started>`.

The following example retrieves statistics about the
``sample_restaurants`` database:

.. io-code-block::
:copyable: true

.. input:: /includes/usage-examples/code-snippets/command.go
:language: go
:dedent:

.. output::
:language: none
:visible: false

// results truncated
{
"avgObjSize": 548.4101901854896,
"collections": 2,
"dataSize": 14014074,
"db": "sample_restaurants",
"indexSize": 286720,
...,
}

.. _addl-info-runcommand:

Additional Information
Expand Down
Loading