Skip to content

Commit eeb51b0

Browse files
author
Chris Cho
authored
DOCSP-9047: TOC landing pages (#72)
* DOCSP-9047: Update ToC landing pages
1 parent 1e67047 commit eeb51b0

File tree

9 files changed

+103
-150
lines changed

9 files changed

+103
-150
lines changed

snooty.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name = "node"
2+
title = "NodeJS"
3+
4+
toc_landing_pages = ["/fundamentals/authentication", "/fundamentals/crud", "/usage-examples"]
25

36
[constants]
47
version = 4.0

source/faq.txt

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ What Is the Difference Between "connectTimeoutMS", "socketTimeoutMS" and "maxTim
2424
- Description
2525
* - connectTimeoutMS
2626
- 30000
27-
- ``connectTimeoutMS`` is a `connection-setting <https://mongodb.github.io/node-mongodb-native/3.5/reference/connecting/connection-settings/>`_ option that sets the time in milliseconds to establish a connection to the MongoDB server before timing out.
27+
- ``connectTimeoutMS`` is a `connection-setting <https://mongodb.github.io/node-mongodb-native/3.5/reference/connecting/connection-settings/>`_ option that sets the time in milliseconds to establish a connection to the MongoDB server before timing out.
2828
* - socketTimeoutMS
2929
- 360000
3030
- ``socketTimeoutMS`` is a ``connection-settings`` option that sets the number of milliseconds a socket stays inactive after the driver has successfully connected before closing the connection.
3131
* - maxTimeMS
3232
- N/A
33-
- :node-api:`maxTimeMS() </Cursor.html#maxTimeMS>` is a :manual:`cursor method </reference/method/js-cursor>` that specifies the max time limit for processing an operation on a cursor. If an operation runs over the time allotted it will return a timeout error.
33+
- :node-api:`maxTimeMS() </Cursor.html#maxTimeMS>` is a :manual:`cursor method </reference/method/js-cursor>` that specifies the max time limit for processing an operation on a cursor. If an operation runs over the time allotted it will return a timeout error.
3434

3535
How Can I Prevent the Driver From Hanging During Connection or From Spending Too Long Trying to Reach Unreachable Replica Sets?
3636
-------------------------------------------------------------------------------------------------------------------------------
@@ -62,10 +62,10 @@ continue to run on the MongoDB server, which could cause data
6262
inconsistencies if the application retries the operation on failure.
6363

6464
However, there are important use cases for ``socketTimeoutMS`` -
65-
consider the following cases:
65+
consider the following cases:
6666

67-
- A MongoDB process erroring out
68-
- A misconfigured firewall causing a socket connection without sending a ``FIN`` packet
67+
- A MongoDB process erroring out
68+
- A misconfigured firewall causing a socket connection without sending a ``FIN`` packet
6969

7070
In those cases, there is no way to detect that the connection has died.
7171
Setting the ``socketTimeoutMS`` is essential to ensure that the sockets
@@ -76,18 +76,18 @@ through the driver.
7676
How Can I Prevent Sockets From Timing out Before They Become Active?
7777
--------------------------------------------------------------------
7878
Having a large connection pool does not always reduce reconnection
79-
requests. Consider the following example:
79+
requests. Consider the following example:
8080

8181
An application has a connection pool size of 5 sockets and has the
8282
``socketTimeoutMS`` option set to 5000 milliseconds. Operations occur,
8383
on average, every 3000 milliseconds, and reconnection requests are
8484
frequent. Each socket times out after 5000 milliseconds, which means
8585
that all sockets must do something during those 5000 milliseconds to
86-
avoid closing.
86+
avoid closing.
8787

8888
One message every 3000 milliseconds is not enough to keep the sockets
8989
active, so several of the sockets will time out after 5000 milliseconds.
90-
Reduce the ``poolSize`` in the connection settings to fix the problem.
90+
Reduce the ``poolSize`` in the connection settings to fix the problem.
9191

9292
What Does a Value of "0" mean for "connectTimeoutMS" and "socketTimeoutMS"?
9393
---------------------------------------------------------------------------
@@ -100,7 +100,7 @@ How Can I Prevent Long-Running Operations From Slowing Down the Server?
100100

101101
By using ``maxTimeMS()`` you can prevent long-running operations from
102102
slowing down the server. This method allows the MongoDB server to cancel
103-
operations that run for more than the set value of ``maxTimeMS``.
103+
operations that run for more than the set value of ``maxTimeMS``.
104104

105105
The following example demonstrates how to use MaxTimeMS with a find
106106
operation:
@@ -125,12 +125,12 @@ What Can I Do If I'm Experiencing Unexpected Network Behavior?
125125
--------------------------------------------------------------
126126
Internal firewalls that exist between application servers and MongoDB
127127
are often misconfigured and are overly aggressive in their removal of
128-
socket connections.
128+
socket connections.
129129

130130
If you experience unexpected network behavior, here
131131
are some things to check:
132132

133-
#. The firewall should send a ``FIN packet`` when closing a socket,allowing the driver to detect that the socket is closed.
133+
#. The firewall should send a ``FIN packet`` when closing a socket,allowing the driver to detect that the socket is closed.
134134
#. The firewall should allow ``keepAlive`` probes.
135135

136136
What Can I Do If I'm Getting "ECONNRESET" When Calling "client.connect()"?
@@ -153,7 +153,7 @@ If this operation causes an ``ECONNRESET`` error, you may have run into
153153
the ``file descriptor`` limit for your Node.js process. In that case you
154154
must increase the number of ``file descriptors`` for the Node.js process. On
155155
MacOS and Linux you do this with the `ulimit
156-
<https://ss64.com/bash/ulimit.html>`_ shell command.
156+
<https://ss64.com/bash/ulimit.html>`_ shell command.
157157

158158
.. code-block:: sh
159159

@@ -178,36 +178,36 @@ other, faster operations.
178178

179179
.. note::
180180
If the number of operations is greater than the set ``poolSize`` and
181-
a slow operation occurs, subsequent operations will be delayed.
181+
a slow operation occurs, subsequent operations will be delayed.
182182

183183
How Can I Ensure My Connection String Is Valid for a Replica Set?
184184
-----------------------------------------------------------------
185185

186186
The connection string passed to the driver must use exact hostnames for
187-
the servers as set in the :manual:`Replica Set Config </reference/replica-configuration/>`.
188-
Given the following configuration settings for your `Replica Set`, in
189-
order for the `Replica Set` discovery and :manual:`failover
187+
the servers as set in the :manual:`Replica Set Config </reference/replica-configuration/>`.
188+
Given the following configuration settings for your Replica Set, in
189+
order for the Replica Set discovery and :manual:`failover
190190
</reference/glossary/#term-failover>` to work the driver should be able
191-
to reach ``server1``, ``server2``, and ``server3``.
192-
193-
.. code-block:: JSON
194-
195-
{
196-
"_id": "testSet",
197-
"version": 1,
198-
"protocolVersion": 1,
199-
"members": [
200-
{
201-
"_id": 1,
202-
"host": "server1:31000"
203-
},
204-
{
205-
"_id": 2,
206-
"host": "server2:31001"
207-
},
208-
{
209-
"_id": 3,
210-
"host": "server3:31002"
211-
}
212-
]
213-
}
191+
to reach ``server1``, ``server2``, and ``server3``.
192+
193+
.. code-block:: JSON
194+
195+
{
196+
"_id": "testSet",
197+
"version": 1,
198+
"protocolVersion": 1,
199+
"members": [
200+
{
201+
"_id": 1,
202+
"host": "server1:31000"
203+
},
204+
{
205+
"_id": 2,
206+
"host": "server2:31001"
207+
},
208+
{
209+
"_id": 3,
210+
"host": "server3:31002"
211+
}
212+
]
213+
}

source/fundamentals/crud.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ Overview
1616
--------
1717

1818
CRUD (Create, Read, Update, Delete) operations allow you to work with
19-
the data stored inside of MongoDB. CRUD operations fall into two
20-
categories: `read operations <crud-read-operations>`_ and
21-
`write operations <crud-write-operations>`_.
19+
the data stored inside of MongoDB. We categorized the CRUD operations into
20+
two sections: :ref:`crud-read-operations` and :ref:`crud-write-operations`.
2221

2322
.. note::
2423

2524
CRUD operations execute **asynchronously** because the driver
2625
communicates with MongoDB over the network, which is subject to
2726
latency, timeouts, and other complications that can delay execution
28-
during synchronous communication. As a result, each CRUD
29-
method returns a Promise that resolves to the output of that
30-
operation. A common method of Promise resolution uses
31-
``async``/``await`` syntax.
27+
during synchronous communication. You can specify a callback in the
28+
CRUD method call to capture the response. If you do not specify a
29+
callback, the operation returns a
30+
:mdn:`Promise <Web/JavaScript/Reference/Global_Objects/Promise>` that
31+
resolves to the output of the operation. We use the ``async``/``await``
32+
syntax for Promise resolution in our examples.
3233

3334
.. _crud-read-operations:
3435

source/fundamentals/crud/read-operations/text.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ words or phrases, instead of matching substrings like
1717
:mdn:`regular expressions
1818
<Web/JavaScript/Guide/Regular_Expressions>`,
1919
also known as RegEx. While regex is very powerful, and MongoDB even
20-
offers a `$regex <>` operator, text searches work particularly well when
20+
offers a ``$regex`` operator, text searches work particularly well when
2121
applied to unstructured text, like transcripts, essays, or even web
2222
pages. Because MongoDB's text indexes are aware of concepts like
2323
plurality, case sensitivity, stop words, whitespace, and punctuation in

source/index.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ material on using the Node.js driver for the following:
7878

7979
Usage Examples
8080
--------------
81-
The :doc:`Usage Examples </usage-examples/overview>` section provides
81+
The :doc:`Usage Examples </usage-examples>` section provides
8282
runnable code snippets and explanations for common methods. We recommend
8383
this section for users that are new to the MongoDB Node.js driver.
8484

8585
API
8686
---
87-
See the :doc:`API </api-documentation/>` section if you are looking for
87+
See the :node-api:`API documentation <>` if you are looking for
8888
technical information about classes, methods, and configuration objects
8989
within the MongoDB Node.js driver.
9090

source/quick-start.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ Next Steps
196196

197197
Learn how to read and modify data in our :doc:`CRUD fundamentals
198198
</fundamentals/crud>` guide, or how to perform common operations in our
199-
:doc:`usage examples </usage-examples/overview>`.
199+
:doc:`usage examples </usage-examples>`.

source/tutorials.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

source/usage-examples.txt

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,8 @@ Usage Examples
44

55
.. default-domain:: mongodb
66

7-
:doc:`bulkWrite </usage-examples/bulkWrite>`
8-
:doc:`countDocuments and estimatedDocumentCount </usage-examples/count>`
9-
:doc:`deleteMany </usage-examples/deleteMany>`
10-
:doc:`insertOne </usage-examples/insertOne>`
11-
:doc:`deleteOne </usage-examples/deleteOne>`
12-
:doc:`find </usage-examples/find>`
13-
:doc:`findOne </usage-examples/findOne>`
14-
:doc:`insertMany </usage-examples/insertMany>`
15-
:doc:`updateOne</usage-examples/updateOne>`
16-
:doc:`updateMany</usage-examples/updateMany>`
17-
:doc:`replaceOne</usage-examples/replaceOne>`
18-
:doc:`distinct</usage-examples/distinct>`
19-
:doc:`command</usage-examples/command>`
20-
:doc:`changeStream</usage-examples/changeStream>`
21-
227
.. toctree::
23-
:caption: Examples
248

25-
/usage-examples/overview
269
/usage-examples/find-operations
2710
/usage-examples/insert-operations
2811
/usage-examples/update-and-replace-operations
@@ -32,3 +15,52 @@ Usage Examples
3215
/usage-examples/command
3316
/usage-examples/changeStream
3417
/usage-examples/bulkWrite
18+
19+
Overview
20+
--------
21+
22+
Usage examples provide convenient starting points for popular MongoDB
23+
operations. Each example provides:
24+
25+
- an explanation of the operation in the example showing the
26+
purpose and a sample use case for the method
27+
28+
- an explanation of how to use the operation, including parameters,
29+
return values, and common exceptions you might encounter
30+
31+
- a full Node.js program that you can copy and paste to run the example
32+
in your own environment
33+
34+
How to Use the Usage Examples
35+
-----------------------------
36+
37+
These examples use the :atlas:`MongoDB Atlas sample data <sample-data>`
38+
database. You can use this sample data on the free tier
39+
of MongoDB Atlas by following the :atlas:`Get Started with Atlas
40+
<getting-started/#atlas-getting-started>` guide or you can
41+
:manual:`import the sample dataset into a local MongoDB instance
42+
</import/>`.
43+
44+
Once you have imported the dataset, you can copy and paste a usage
45+
example into your development environment of choice. You can follow the
46+
:doc:`quick start guide </quick-start>` to learn more about getting
47+
started with Node.js, npm, and the Node.js driver. Once you've copied
48+
a usage example, you'll have to edit one line to get the example running
49+
with your instance of MongoDB:
50+
51+
.. code-block:: javascript
52+
53+
// Replace the following with your MongoDB deployment's connection string.
54+
const uri =
55+
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
56+
57+
You can use the :guides:`Atlas Connectivity Guide
58+
</cloud/connectionstring/>` to enable connectivity to your instance of
59+
Atlas and find the :manual:`connection string
60+
</reference/connection-string/>` to replace the ``uri`` variable in the
61+
usage example. If your instance uses :manual:`SCRAM authentication
62+
</core/security-scram/>`, you can replace ``<user>`` with your username,
63+
``<password>`` with your password, and ``<cluster-url>`` with the IP
64+
address or URL of your instance. Consult the
65+
:doc:`Connection Guide </fundamentals/connection>` for more information
66+
about getting connected to your MongoDB instance.

source/usage-examples/overview.txt

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)