|
4 | 4 | .. step:: Create your Node.js Application
|
5 | 5 |
|
6 | 6 | Create a file to contain your application called ``index.js`` in your
|
7 |
| - ``node_quickstart`` project directory. Paste the following code into |
8 |
| - the file, assigning |
9 |
| - the ``uri`` variable the value of your connection string. |
10 |
| - |
| 7 | + ``node_quickstart`` project directory. |
| 8 | + |
| 9 | + Copy and paste the following code into the ``index.js`` file: |
| 10 | + |
11 | 11 | .. code-block:: js
|
12 | 12 |
|
13 | 13 | const { MongoClient } = require("mongodb");
|
14 | 14 |
|
15 | 15 | // Replace the uri string with your connection string.
|
16 |
| - const uri = |
17 |
| - "mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority"; |
| 16 | + const uri = "<connection string uri>"; |
18 | 17 |
|
19 | 18 | const client = new MongoClient(uri);
|
20 | 19 |
|
|
47 | 46 |
|
48 | 47 | const MongoClient = require("mongodb").MongoClient;
|
49 | 48 |
|
| 49 | + .. step:: Assign the Connection String |
| 50 | + |
| 51 | + Replace the ``<connection string uri>`` placeholder in |
| 52 | + ``index.js`` with the connection string that you |
| 53 | + copied from the :ref:`quick-start-connection-string` step |
| 54 | + in this guide. |
| 55 | + |
50 | 56 | .. step:: Run your Node.js Application
|
51 | 57 |
|
52 | 58 | Run the application you created from the previous step from the
|
|
73 | 79 | proper connection string in the application code, and loaded the sample
|
74 | 80 | data set in your Atlas cluster.
|
75 | 81 |
|
76 |
| - At this point, you should have a working application that uses |
77 |
| - the {+driver-short+} to connect to your MongoDB instance, runs a query |
78 |
| - on the sample data, and prints out the result. |
| 82 | + After completing this step, you should have a working application that |
| 83 | + uses the driver to connect to your MongoDB instance, runs a query on |
| 84 | + the sample data, and prints out the result. |
0 commit comments