@@ -39,88 +39,49 @@ in your development environment.
39
39
For information on how to install Node.js and npm, see
40
40
`downloading and installing Node.js and npm <https://docs.npmjs.com/downloading-and-installing-node-js-and-npm>`__.
41
41
42
- Select the :guilabel:`Clone the Project` tab if you want to build your
43
- project from a premade dependency file or the :guilabel:`Create the Project`
44
- tab if you want to create the project dependency file yourself.
45
42
46
- .. tabs::
43
+ Create the Project
44
+ ~~~~~~~~~~~~~~~~~~
47
45
48
- .. tab:: Clone the Project
49
- :tabid: clone the project
46
+ First, in your shell, create a directory for your project:
50
47
51
- Ensure you have git installed in your development environment.
48
+ .. code-block:: bash
52
49
53
- For information on how to install git, see `Git - Getting Started Guide <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`__.
50
+ mkdir node_quickstart
54
51
55
- Then, from your shell, clone the `js-starter repository
56
- <https://github.com/mongodb-university/js-starter>`__:
52
+ Then, navigate into that directory:
57
53
58
- .. code-block:: bash
54
+ .. code-block:: bash
59
55
60
- git clone --branch v{+version+} https://github.com/mongodb-university/js-starter.git
56
+ cd node_quickstart
61
57
62
- Next, navigate into the repository :
58
+ Next, initialize your project :
63
59
64
- .. code-block:: bash
60
+ .. code-block:: bash
65
61
66
- cd js-starter
62
+ npm init -y
67
63
68
- Then, install the {+driver-short+}:
64
+ Add MongoDB as a Dependency
65
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
66
70
- .. code-block:: bash
67
+ Install the {+driver-short+}:
71
68
72
- npm install
69
+ .. code-block:: bash
73
70
74
- This command performs the following actions:
71
+ npm install mongodb@{+version+}
75
72
76
- - Downloads and saves the ``mongodb`` package in a directory
77
- called ``node_modules``
78
- - Installs ``eslint``, which the project uses to identify and
79
- report issues in your code
80
- - Installs ``prettier``, which the project uses to format your code
73
+ This command performs the following actions:
81
74
82
- .. tab:: Create the Project
83
- :tabid: create the project
84
-
85
- First, in your shell, create a directory for your project:
86
-
87
- .. code-block:: bash
88
-
89
- mkdir node_quickstart
90
-
91
- Then, navigate into that directory:
92
-
93
- .. code-block:: bash
94
-
95
- cd node_quickstart
96
-
97
- Next, initialize your project:
98
-
99
- .. code-block:: bash
100
-
101
- npm init -y
102
-
103
- .. tip:: Why the -y?
104
-
105
- If you specify the ``-y`` option in the command, npm uses the
106
- default values for your project settings. If you want to
107
- interactively select your project settings, omit the ``-y`` flag.
108
-
109
- Then, install the {+driver-short+}:
110
-
111
- .. code-block:: bash
112
-
113
- npm install mongodb@{+version+}
114
-
115
- This command performs the following actions:
116
-
117
- - Downloads the ``mongodb`` package and the dependencies it requires
118
- - Saves the package in the ``node_modules`` directory
119
- - Records the dependency information in the ``package.json`` file
75
+ - Downloads the ``mongodb`` package and the dependencies it requires
76
+ - Saves the package in the ``node_modules`` directory
77
+ - Records the dependency information in the ``package.json`` file
120
78
121
79
At this point, you are ready to use the {+driver-short+} with your
122
80
application.
123
81
82
+ Create a MongoDB Cluster
83
+ ~~~~~~~~~~~~~~~~~~~~~~~~
84
+
124
85
.. procedure::
125
86
:style: connected
126
87
@@ -161,6 +122,12 @@ application.
161
122
162
123
Save your connection string to a safe location.
163
124
125
+ Connect to Your Application
126
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
127
+
128
+ .. procedure::
129
+ :style: connected
130
+
164
131
.. step:: Create your Node.js Application
165
132
166
133
Create a file to contain your application called ``index.js`` in your
@@ -174,7 +141,7 @@ application.
174
141
175
142
// Replace the uri string with your connection string.
176
143
const uri =
177
- "mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&writeConcern =majority";
144
+ "mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w =majority";
178
145
179
146
const client = new MongoClient(uri);
180
147
0 commit comments