Skip to content

Commit 3db8fe9

Browse files
DOCSP-16492 added sidebar TOC to all pages (#96)
* added sidebar TOC to all pages
1 parent 8682718 commit 3db8fe9

File tree

13 files changed

+87
-29
lines changed

13 files changed

+87
-29
lines changed

source/fundamentals/builders.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Builders
33
========
44

55
.. default-domain:: mongodb
6-
6+
77
.. toctree::
88

99
/fundamentals/builders/aggregates

source/fundamentals/connection.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Connection Guide
33
================
44

55
.. default-domain:: mongodb
6-
6+
77
.. toctree::
88

99
/fundamentals/connection/tls

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Access Data From a Cursor
99
:backlinks: none
1010
:depth: 2
1111
:class: singlecol
12-
12+
1313
Read operations that return multiple documents do not immediately return
1414
all values matching the query. Because a query can potentially match
1515
large number of documents, we need to be able to access or store the

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Limit the Number of Returned Results
44

55
.. default-domain:: mongodb
66

7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Overview
14+
--------
15+
716
Use ``limit()`` to cap the number of documents that a read operation returns.
817
This instance method designates the maximum number of
918
documents that a read operation can return. If there are not enough documents
@@ -16,6 +25,9 @@ The examples below demonstrate, respectively, how to insert data into
1625
a collection, how to use ``limit()`` to restrict the number of returned documents,
1726
and how to combine ``limit()`` with ``skip()`` to further narrow the results returned from a query.
1827

28+
Sample Documents
29+
~~~~~~~~~~~~~~~~
30+
1931
The following operation inserts documents representing books into a collection:
2032

2133
.. code-block:: java
@@ -37,6 +49,9 @@ The following operation inserts documents representing books into a collection:
3749
.append("author", "Martin")
3850
));
3951

52+
Specify a Limit
53+
---------------
54+
4055
The next example queries the collection to return the top three
4156
longest books. It first matches all the documents with the query, then sorts on the
4257
``length`` field to return books with longer lengths before
@@ -63,7 +78,6 @@ books with shorter lengths. Lastly, it limits the return value to ``3`` document
6378
cursor.close();
6479
}
6580

66-
6781
The code example above prints out the following three documents, sorted by
6882
length:
6983

@@ -84,6 +98,8 @@ length:
8498
collection.find().sort(descending("length")).limit(3);
8599
collection.find().limit(3).sort(descending("length"));
86100

101+
Combining Skip and Limit
102+
------------------------
87103

88104
To see the next three longest books, append the ``skip()`` method to your
89105
``find()`` call. The integer argument passed to ``skip()`` will determine
@@ -131,8 +147,6 @@ collection, returning only small subsets of the collection at one time.
131147
could return different documents for different queries. In this case, sorting
132148
by ``data`` or ``serial_no`` would guarantee a stable sort, as both are unique keys.
133149

134-
135-
136150
For additional information on the classes and methods mentioned on this
137151
page, see the following API documentation:
138152

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Skip Returned Results
44

55
.. default-domain:: mongodb
66

7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
713
In this guide, we show you how to skip a specified number of returned results.
814

915
You can skip results on the returned results of a query by using the
@@ -33,7 +39,7 @@ You can use the ``Aggregates.skip()`` method to skip the first two documents as
3339
collection.aggregate(Arrays.asList(Aggregates.match(), Aggregates.skip(2)));
3440

3541
Examples
36-
~~~~~~~~
42+
--------
3743

3844
The following example is about a paint store that sells eight different
3945
colors of paint. The best colors sell quicker than the other colors.
@@ -57,8 +63,8 @@ To address the scenario, the paint store needs to query the
5763
``paint_inventory`` collection with an empty filter, sort the documents
5864
by ``qty`` field and omit the first five results.
5965

60-
Using the ``skip()`` method:
61-
````````````````````````````
66+
Using a FindIterable
67+
~~~~~~~~~~~~~~~~~~~~
6268

6369
.. literalinclude:: /includes/fundamentals/code-snippets/Skip.java
6470
:language: java
@@ -70,8 +76,8 @@ Using the ``skip()`` method:
7076
- The ``sort()`` method specifies documents to display from highest to lowest based on the ``qty`` field.
7177
- The ``skip()`` method specifies to omit the first five documents.
7278

73-
Using ``Aggregates.skip()``:
74-
````````````````````````````
79+
Using Aggregation
80+
~~~~~~~~~~~~~~~~~
7581

7682
.. literalinclude:: /includes/fundamentals/code-snippets/Skip.java
7783
:language: java

source/fundamentals/crud/write-operations/change-a-document.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Change a Document
44

55
.. default-domain:: mongodb
66

7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
713
In this page, you can learn how to change documents in a MongoDB collection
814
using two distinct operation types:
915

@@ -49,8 +55,8 @@ You can call the ``updateOne()`` and ``updateMany()`` methods on a
4955

5056
collection.updateMany(query, updateDocument);
5157

52-
Update Operation Parameters:
53-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
Update Operation Parameters
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5460

5561
- ``query`` specifies a query filter with the criteria to match documents to update in your collection
5662
- ``updateDocument`` specifies the fields and values to change in the matching document or documents. For this example, we use the :doc:`Updates builder </fundamentals/builders/updates>` to create the update document.
@@ -66,7 +72,7 @@ See the MongoDB API documentation for a :java-core-api:`complete list of
6672
Updates builders and their usage <com/mongodb/client/model/Updates.html>`.
6773

6874
Example
69-
~~~~~~~
75+
```````
7076

7177
The paint store receives a fresh shipment and needs to update their inventory.
7278
The shipment contains 20 cans of each paint color.
@@ -134,14 +140,14 @@ instance as follows:
134140

135141
collection.replaceOne(query, replacementDocument);
136142

137-
Replace Operation Parameters:
138-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143+
Replace Operation Parameters
144+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139145

140146
- ``query`` specifies a query filter with the criteria to match a document to replace in your collection
141147
- ``replacementDocument`` specifies fields and values of a new ``Document`` object to replace in the matched document
142148

143149
Example
144-
~~~~~~~
150+
```````
145151

146152
The paint store realizes they need to update their inventory again. What they
147153
thought was 20 cans of pink paint is actually 25 cans of orange paint.

source/fundamentals/crud/write-operations/delete.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Delete a Document
44

55
.. default-domain:: mongodb
66

7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
713
Overview
814
--------
915

@@ -31,8 +37,8 @@ projection on the returned document, use
3137
:java-docs:`FindOneAndDeleteOptions </apidocs/mongodb-driver-core/com/mongodb/client/model/FindOneAndDeleteOptions.html>`
3238
as the second parameter to the ``findOneAndDelete()`` method.
3339

34-
Examples
35-
--------
40+
Sample Documents
41+
~~~~~~~~~~~~~~~~
3642

3743
The following examples are about a paint store that sells eight different
3844
colors of paint. The store had their annual online sale resulting in the
@@ -49,8 +55,8 @@ following documents in their ``paint_inventory`` collection:
4955
{ "_id": 7, "color": "green", "qty": 0 }
5056
{ "_id": 8, "color": "black", "qty": 8 }
5157

52-
``deleteMany()``
53-
````````````````
58+
Delete Many Documents
59+
---------------------
5460

5561
The paint store website displays all documents in the
5662
``paint_inventory`` collection. To reduce customer confusion, the store
@@ -76,8 +82,8 @@ collection:
7682
{ "_id": 5, "color": "yellow", "qty": 6 }
7783
{ "_id": 8, "color": "black", "qty": 8 }
7884

79-
``deleteOne()``
80-
```````````````
85+
Delete a Document
86+
-----------------
8187

8288
The store is donating the remaining quantity of their yellow paint. This
8389
means that the ``qty`` for yellow is now ``0`` and we need to remove yellow
@@ -102,8 +108,8 @@ collection:
102108
{ "_id": 2, "color": "purple", "qty": 8 }
103109
{ "_id": 8, "color": "black", "qty": 8 }
104110

105-
``findOneAndDelete()``
106-
``````````````````````
111+
Find and Delete a Document
112+
--------------------------
107113

108114
The store would like to raffle the remaining quantity of purple paint
109115
and remove purple from the ``paint_inventory`` collection.

source/fundamentals/crud/write-operations/upsert.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Insert or Update in a Single Operation
33
======================================
44

5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
513
Applications use insert and update operations to store and modify data.
614
Sometimes, you need to choose between an insert and update depending on
715
whether the document exists. MongoDB simplifies this decision for us
@@ -12,8 +20,8 @@ An ``upsert``:
1220
- Updates documents that match your query filter
1321
- Inserts a document if there are no matches to your query filter
1422

15-
Specify an Upsert:
16-
------------------
23+
Specify an Upsert
24+
-----------------
1725

1826
To specify an upsert with the ``updateOne()`` or ``updateMany()``
1927
methods, pass ``true`` to :java-docs:`UpdateOptions.upsert()

source/fundamentals/data-formats/documents.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ For more information on this class, see the
287287
:java-docs:`BsonDocument API documentation </apidocs/bson/org/bson/BsonDocument.html>`.
288288

289289
JsonObject
290-
-------------
290+
----------
291291

292292
The ``JsonObject`` class acts as a wrapper for JSON strings.
293293
If you only want to work with JSON data, you can use ``JsonObject``

source/fundamentals/databases-collections.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Databases and Collections
44

55
.. default-domain:: mongodb
66

7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
713
Overview
814
--------
915

0 commit comments

Comments
 (0)