@@ -7,11 +7,13 @@ Builders
7
7
.. toctree::
8
8
9
9
/fundamentals/builders/aggregates
10
- /fundamentals/builders/filters
11
- /fundamentals/builders/indexes
12
- /fundamentals/builders/projections
13
- /fundamentals/builders/sort
14
- /fundamentals/builders/updates
10
+
11
+ .. TODO: add these back after Must-Have phase complete
12
+ .. /fundamentals/builders/filters
13
+ .. /fundamentals/builders/indexes
14
+ .. /fundamentals/builders/projections
15
+ .. /fundamentals/builders/sort
16
+ .. /fundamentals/builders/updates
15
17
16
18
.. contents:: On this page
17
19
:local:
@@ -23,10 +25,10 @@ Overview
23
25
--------
24
26
25
27
This section includes guides on how to use each of the available
26
- builders, and demonstrates the utility the MongoDB Java driver builder classes
28
+ builders, and demonstrates the utility the MongoDB Kotlin driver builder classes
27
29
provide.
28
30
29
- The Java driver provides classes to simplify the process for developers
31
+ The Kotlin driver provides classes to simplify the process for developers
30
32
to use CRUD operations and the Aggregation API. The static utility methods allow you
31
33
to build a query more efficiently.
32
34
@@ -35,11 +37,11 @@ Why Use Builders?
35
37
36
38
Using the builders class, you leverage the power of:
37
39
38
- - The Java compiler and the IDE to find errors during development
40
+ - The Kotlin compiler and the IDE to find errors during development
39
41
- The IDE for discovery and code completion
40
42
41
- When using builders, the Java compiler and the IDE catch errors such as misspelled
42
- operators early on. When using the MongoDB shell or plain Java , you
43
+ When using builders, the Kotlin compiler and the IDE catch errors such as misspelled
44
+ operators early on. When using the MongoDB shell or plain Kotlin , you
43
45
write operators as strings and get no visual indication of a problem,
44
46
pushing these errors to runtime instead of compile time
45
47
@@ -61,6 +63,12 @@ collection with the following criteria:
61
63
We only want their email address, so we'll ensure our query doesn't
62
64
return data we pay bandwidth costs for but don't need.
63
65
66
+ The documents in the ``users`` collection are modeled with the following data class
67
+ in our application:
68
+
69
+ .. literalinclude:: /examples/generated/BuildersTest.snippet.user-data-class.kt
70
+ :language: kotlin
71
+
64
72
Using the MongoDB Shell
65
73
~~~~~~~~~~~~~~~~~~~~~~~
66
74
@@ -71,32 +79,29 @@ Using the MongoDB Shell
71
79
Without Using Builders
72
80
~~~~~~~~~~~~~~~~~~~~~~
73
81
74
- .. code-block:: java
75
-
76
- Bson filter = new Document().append("gender", "female").append("age", new Document().append("$gt", 29));
77
- Bson projection = new Document().append("_id", 0).append("email", 1);
78
- collection.find(filter).projection(projection);
82
+ .. literalinclude:: /examples/generated/BuildersTest.snippet.no-builders.kt
83
+ :language: kotlin
79
84
80
85
Using Builders
81
86
~~~~~~~~~~~~~~
82
87
83
- .. code-block:: java
88
+ .. code-block:: kotlin
84
89
85
- import static com.mongodb.client.model.Filters.*;
86
- import static com.mongodb.client.model.Projections.*;
87
- ...
90
+ import com.mongodb.client.model.Filters.*
91
+ import com.mongodb.client.model.Projections.*
88
92
89
- Bson filter = and(eq("gender", "female"), gt("age", 29));
90
- Bson projection = fields(excludeId(), include("email"));
91
- collection.find(filter).projection(projection);
93
+ .. literalinclude:: /examples/generated/BuildersTest.snippet.builders.kt
94
+ :language: kotlin
92
95
93
96
Available Builders
94
97
------------------
95
98
96
- - :ref:`Filters <filters-builders>` for building query filters.
97
- - :ref:`Projections <projections-builders>` for building projections.
98
- - :ref:`Sorts <sorts-builders>` for building sort criteria.
99
- - :ref:`Updates <updates-builders>` for building updates.
100
99
- :ref:`Aggregates <aggregates-builders>` for building aggregation pipelines.
101
- - :ref:`Indexes <indexes-builders>` for creating index keys.
100
+
101
+ .. TODO: add these back after Must-Have phase complete
102
+ .. - :ref:`Filters <filters-builders>` for building query filters.
103
+ .. - :ref:`Projections <projections-builders>` for building projections.
104
+ .. - :ref:`Sorts <sorts-builders>` for building sort criteria.
105
+ .. - :ref:`Updates <updates-builders>` for building updates.
106
+ .. - :ref:`Indexes <indexes-builders>` for creating index keys.
102
107
0 commit comments