Skip to content

Commit

Permalink
cleanup app section
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmarie17 committed Jan 31, 2025
1 parent b367d65 commit bd47241
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions source/quick-start.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,59 @@ Create a MongoDB Cluster
Query Your MongoDB Cluster from Your Application
------------------------------------------------

Next, create a file to contain your application called ``main.go``
in the base directory of your project. Use the following sample
code to run a query on your sample dataset in MongoDB Atlas.
.. procedure::
:style: connected

.. step:: Create a new file

Create a new file called ``main.go`` in the base directory of your project.

.. code-block:: shell

touch main.go

.. step:: Add your connection string

Specify your MongoDB Atlas connection string as the value of the
``uri`` variable or create an environment variable called
``MONGODB_URI`` and set your Atlas connection string as its value.

.. code-block:: bash

export MONGODB_URI='<your atlas connection string>'

Specify your MongoDB Atlas connection string as the value of the
``uri`` variable, or create an environment variable called
``MONGODB_URI`` and set your Atlas connection string as its value.
.. note::

.. code-block:: bash
Make sure to replace the "<password>" section of the connection string with
the password you created for your user that has **atlasAdmin** permissions.

export MONGODB_URI='<your atlas connection string>'
.. step:: Create your Go application

.. note::
Copy and paste the following code into your ``main.go`` file. This code
runs a query on your sample dataset in MongoDB Atlas.

Make sure to replace the "<password>" section of the connection string with
the password you created for your user that has **atlasAdmin** permissions.
.. literalinclude:: /includes/quick-start/main.go
:language: go
:dedent: 3

.. literalinclude:: /includes/quick-start/main.go
:language: go
:dedent:
.. step:: Run your application

Run the sample code with the following command from your command line:
Run the sample code with the following command from your command line:

.. code-block:: bash
.. code-block:: bash

go run main.go
go run main.go

.. include:: /includes/quick-start/query-output.rst
.. include:: /includes/quick-start/query-output.rst

.. tip::
.. tip::

If your output is empty, ensure you have loaded the
:atlas:`sample datasets </sample-data/>` into your cluster.
If your output is empty, ensure you have loaded the
:atlas:`sample datasets </sample-data/>` into your cluster.

After completing this step, you have a working application that uses
the Go driver to connect to your MongoDB cluster, run a query on the
sample data, and print out the result.
After you complete these steps, you have a working application that uses
the Go driver to connect to your MongoDB cluster, runs a query on the
sample data, and prints out the result.

Next Steps
----------
Expand Down

0 comments on commit bd47241

Please sign in to comment.