@@ -14,6 +14,40 @@ Quick Start
14
14
15
15
.. include:: /includes/quick-start/overview.rst
16
16
17
+ Create a MongoDB Cluster
18
+ ------------------------
19
+
20
+ Set Up a Free Tier Cluster in Atlas
21
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
+
23
+ To set up your Atlas Free Tier Cluster required for this guide, complete the guide on
24
+ :guides:`MongoDB Atlas Setup </atlas/account>`.
25
+
26
+ After completing the steps in the Atlas guide, you have a new MongoDB
27
+ cluster deployed in Atlas, a new database user, and
28
+ :atlas:`sample datasets loaded </sample-data/>` into your cluster. You also have
29
+ a connection string similar to the following in your copy buffer:
30
+
31
+ .. code-block:: bash
32
+
33
+ "mongodb+srv://<username>:<password>@cluster0.abc.mongodb.net/?retryWrites=true&w=majority"
34
+
35
+ Set Your Connection String
36
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
37
+
38
+ Run the following code at the command prompt to save your MongoDB connection string to an
39
+ environment variable. This method is safer than including your credentials in your source
40
+ code.
41
+
42
+ .. code-block:: bash
43
+
44
+ export MONGODB_URI='<your MongoDB connection string>'
45
+
46
+ .. important::
47
+
48
+ Make sure to replace the ``<username>`` and ``<password>`` sections of the connection
49
+ string with the username and password of your Atlas user.
50
+
17
51
Set Up Your Project
18
52
-------------------
19
53
@@ -39,32 +73,21 @@ Use the ``dotnet add`` command to add the {+driver-short+} to your project as a
39
73
40
74
dotnet add package MongoDB.Driver
41
75
42
- Create a MongoDB Cluster
43
- ------------------------
44
-
45
- .. include:: /includes/quick-start/atlas-setup.rst
46
-
47
76
Query Your MongoDB Cluster from Your Application
48
77
------------------------------------------------
49
78
50
- First, save your Atlas connection string to an environment variable named ``MONGODB_URI``. This prevents potential security issues caused by including your credentials in the source code.
79
+ In this step, you'll use the {+driver-short+}
80
+ to connect to your MongoDB cluster and run a query on the sample data.
51
81
52
- .. code-block:: bash
53
-
54
- export MONGODB_URI='<your atlas connection string>'
55
-
56
- .. important::
57
-
58
- Make sure to replace the "<username>" and "<password>" sections of the connection string with the username and password of your Atlas user.
59
-
60
- Next, open the file named ``Program.cs`` in the base directory of your project. Copy the
82
+ Open the file named ``Program.cs`` in the base directory of your project. Copy the
61
83
following sample code into ``Program.cs``
62
84
63
85
.. literalinclude:: /includes/quick-start/Program.cs
64
86
:language: csharp
65
87
:dedent:
66
88
67
- The sample code runs a query against your sample dataset in MongoDB Atlas. Run the sample code with the following command from your command line:
89
+ This sample code runs a query against your sample dataset in MongoDB Atlas. Run it
90
+ from your command line by using the following command:
68
91
69
92
.. code-block:: bash
70
93
@@ -81,7 +104,12 @@ After completing this step, you should have a working application that uses
81
104
the {+driver-short+} to connect to your MongoDB cluster, run a query on the
82
105
sample data, and print out the result.
83
106
107
+ To learn more about connecting to Atlas with the {+driver-short+}, see
108
+ the :atlas:`Atlas driver connection </driver-connection>` guide
109
+ and select :guilabel:`{+language+}` from the :guilabel:`Select your language` dropdown.
110
+
84
111
Next steps
85
112
----------
86
113
87
- .. include:: /includes/quick-start/next-steps.rst
114
+ Learn how to read and modify data using the {+driver-short+} in the CRUD Operations
115
+ guide or how to perform common operations in Usage Examples.
0 commit comments