Skip to content

Commit ffe8403

Browse files
authored
Update Javadoc for Projections. (#1216)
1 parent a45742a commit ffe8403

File tree

8 files changed

+36
-4
lines changed

8 files changed

+36
-4
lines changed

driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public Bson getProjection() {
5959
* @param projection the project document, which may be null.
6060
* @return this
6161
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
62+
* @see Projections
6263
*/
6364
public FindOneAndDeleteOptions projection(@Nullable final Bson projection) {
6465
this.projection = projection;

driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public Bson getProjection() {
6262
* @param projection the project document, which may be null.
6363
* @return this
6464
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
65+
* @see Projections
6566
*/
6667
public FindOneAndReplaceOptions projection(@Nullable final Bson projection) {
6768
this.projection = projection;

driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public Bson getProjection() {
6464
* @param projection the project document, which may be null.
6565
* @return this
6666
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
67+
* @see Projections
6768
*/
6869
public FindOneAndUpdateOptions projection(@Nullable final Bson projection) {
6970
this.projection = projection;

driver-core/src/main/com/mongodb/client/model/Projections.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,20 @@ private Projections() {
5252
}
5353

5454
/**
55-
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported
56-
* using the $project aggregation pipeline stage.
55+
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the
56+
* following contexts:
57+
* <ul>
58+
* <li>$project aggregation pipeline stage.</li>
59+
* <li>Starting from MongoDB 4.4, it's also accepted in various find-related methods within the
60+
* {@code MongoCollection}-based API where projection is supported, for example:
61+
* <ul>
62+
* <li>{@code find()}</li>
63+
* <li>{@code findOneAndReplace()}</li>
64+
* <li>{@code findOneAndUpdate()}</li>
65+
* <li>{@code findOneAndDelete()}</li>
66+
* </ul>
67+
* </li>
68+
* </ul>
5769
*
5870
* @param fieldName the field name
5971
* @param expression the expression

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mongodb.CursorType;
2020
import com.mongodb.ExplainVerbosity;
2121
import com.mongodb.client.model.Collation;
22+
import com.mongodb.client.model.Projections;
2223
import com.mongodb.lang.Nullable;
2324
import org.bson.BsonValue;
2425
import org.bson.Document;
@@ -104,6 +105,7 @@ public interface FindPublisher<TResult> extends Publisher<TResult> {
104105
* @param projection the project document, which may be null.
105106
* @return this
106107
* @mongodb.driver.manual reference/method/db.collection.find/ Projection
108+
* @see Projections
107109
*/
108110
FindPublisher<TResult> projection(@Nullable Bson projection);
109111
/**

driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ case class FindObservable[TResult](private val wrapped: FindPublisher[TResult])
121121
* [[https://www.mongodb.com/docs/manual/reference/method/db.collection.find/ Projection]]
122122
* @param projection the project document, which may be null.
123123
* @return this
124+
* @see [[org.mongodb.scala.model.Projections]]
124125
*/
125126
def projection(projection: Bson): FindObservable[TResult] = {
126127
wrapped.projection(projection)

driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ import org.mongodb.scala.bson.conversions.Bson
3232
object Projections {
3333

3434
/**
35-
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported
36-
* using the `\$project` aggregation pipeline stage.
35+
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the
36+
* following contexts:
37+
* <ul>
38+
* <li>$project aggregation pipeline stage.</li>
39+
* <li>Starting from MongoDB 4.4, it's also accepted in various find-related methods within the
40+
* `MongoCollection`-based API where projection is supported, for example:
41+
* <ul>
42+
* <li>`find()`</li>
43+
* <li>`findOneAndReplace()`</li>
44+
* <li>`findOneAndUpdate()`</li>
45+
* <li>`findOneAndDelete()`</li>
46+
* </ul>
47+
* </li>
48+
* </ul>
3749
*
3850
* @param fieldName the field name
3951
* @param expression the expression

driver-sync/src/main/com/mongodb/client/FindIterable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.mongodb.CursorType;
2020
import com.mongodb.ExplainVerbosity;
2121
import com.mongodb.client.model.Collation;
22+
import com.mongodb.client.model.Projections;
2223
import com.mongodb.lang.Nullable;
2324
import org.bson.BsonValue;
2425
import org.bson.Document;
@@ -96,6 +97,7 @@ public interface FindIterable<TResult> extends MongoIterable<TResult> {
9697
* @param projection the project document, which may be null.
9798
* @return this
9899
* @mongodb.driver.manual reference/method/db.collection.find/ Projection
100+
* @see Projections
99101
*/
100102
FindIterable<TResult> projection(@Nullable Bson projection);
101103

0 commit comments

Comments
 (0)