Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Javadoc for Projections. #1216

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Bson getProjection() {
* @param projection the project document, which may be null.
* @return this
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
* @see Projections
*/
public FindOneAndDeleteOptions projection(@Nullable final Bson projection) {
this.projection = projection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Bson getProjection() {
* @param projection the project document, which may be null.
* @return this
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
* @see Projections
*/
public FindOneAndReplaceOptions projection(@Nullable final Bson projection) {
this.projection = projection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Bson getProjection() {
* @param projection the project document, which may be null.
* @return this
* @mongodb.driver.manual tutorial/project-fields-from-query-results Projection
* @see Projections
*/
public FindOneAndUpdateOptions projection(@Nullable final Bson projection) {
this.projection = projection;
Expand Down
16 changes: 14 additions & 2 deletions driver-core/src/main/com/mongodb/client/model/Projections.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,20 @@ private Projections() {
}

/**
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported
* using the $project aggregation pipeline stage.
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the
* following contexts:
* <ul>
* <li>$project aggregation pipeline stage.</li>
* <li>Starting from MongoDB 4.4, it's also accepted in various find-related methods within the
* {@code MongoCollection}-based API where projection is supported, for example:
* <ul>
* <li>{@code find()}</li>
* <li>{@code findOneAndReplace()}</li>
* <li>{@code findOneAndUpdate()}</li>
* <li>{@code findOneAndDelete()}</li>
* </ul>
* </li>
* </ul>
*
* @param fieldName the field name
* @param expression the expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mongodb.CursorType;
import com.mongodb.ExplainVerbosity;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.Projections;
import com.mongodb.lang.Nullable;
import org.bson.BsonValue;
import org.bson.Document;
Expand Down Expand Up @@ -104,6 +105,7 @@ public interface FindPublisher<TResult> extends Publisher<TResult> {
* @param projection the project document, which may be null.
* @return this
* @mongodb.driver.manual reference/method/db.collection.find/ Projection
* @see Projections
*/
FindPublisher<TResult> projection(@Nullable Bson projection);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ case class FindObservable[TResult](private val wrapped: FindPublisher[TResult])
* [[https://www.mongodb.com/docs/manual/reference/method/db.collection.find/ Projection]]
* @param projection the project document, which may be null.
* @return this
* @see [[org.mongodb.scala.model.Projections]]
*/
def projection(projection: Bson): FindObservable[TResult] = {
wrapped.projection(projection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,20 @@ import org.mongodb.scala.bson.conversions.Bson
object Projections {

/**
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported
* using the `\$project` aggregation pipeline stage.
* Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the
* following contexts:
* <ul>
* <li>$project aggregation pipeline stage.</li>
* <li>Starting from MongoDB 4.4, it's also accepted in various find-related methods within the
* `MongoCollection`-based API where projection is supported, for example:
* <ul>
* <li>`find()`</li>
* <li>`findOneAndReplace()`</li>
* <li>`findOneAndUpdate()`</li>
* <li>`findOneAndDelete()`</li>
* </ul>
* </li>
* </ul>
*
* @param fieldName the field name
* @param expression the expression
Expand Down
2 changes: 2 additions & 0 deletions driver-sync/src/main/com/mongodb/client/FindIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mongodb.CursorType;
import com.mongodb.ExplainVerbosity;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.Projections;
import com.mongodb.lang.Nullable;
import org.bson.BsonValue;
import org.bson.Document;
Expand Down Expand Up @@ -96,6 +97,7 @@ public interface FindIterable<TResult> extends MongoIterable<TResult> {
* @param projection the project document, which may be null.
* @return this
* @mongodb.driver.manual reference/method/db.collection.find/ Projection
* @see Projections
*/
FindIterable<TResult> projection(@Nullable Bson projection);

Expand Down