public final class Projections extends Object
collection.find().projection(fields(include("x", "y"), excludeId()))
Modifier and Type | Method | Description |
---|---|---|
static <TExpression> |
computedβ(String fieldName,
TExpression expression) |
Creates a projection of a field whose value is computed from the given expression.
|
static Bson |
elemMatchβ(String fieldName) |
Creates a projection that includes for the given field only the first element of an array that matches the query filter.
|
static Bson |
elemMatchβ(String fieldName,
Bson filter) |
Creates a projection that includes for the given field only the first element of the array value of that field that matches the given
query filter.
|
static Bson |
excludeβ(String... fieldNames) |
Creates a projection that excludes all of the given fields.
|
static Bson |
excludeβ(List<String> fieldNames) |
Creates a projection that excludes all of the given fields.
|
static Bson |
excludeIdβ() |
Creates a projection that excludes the _id field.
|
static Bson |
fieldsβ(List<? extends Bson> projections) |
Creates a projection that combines the list of projections into a single one.
|
static Bson |
fieldsβ(Bson... projections) |
Creates a projection that combines the list of projections into a single one.
|
static Bson |
includeβ(String... fieldNames) |
Creates a projection that includes all of the given fields.
|
static Bson |
includeβ(List<String> fieldNames) |
Creates a projection that includes all of the given fields.
|
static Bson |
metaTextScoreβ(String fieldName) |
Creates a projection to the given field name of the textScore, for use with text queries.
|
static Bson |
sliceβ(String fieldName,
int limit) |
Creates a projection to the given field name of a slice of the array value of that field.
|
static Bson |
sliceβ(String fieldName,
int skip,
int limit) |
Creates a projection to the given field name of a slice of the array value of that field.
|
public static <TExpression> Bson computedβ(String fieldName, TExpression expression)
TExpression
- the expression typefieldName
- the field nameexpression
- the expressionAggregates.project(Bson)
public static Bson includeβ(String... fieldNames)
fieldNames
- the field namespublic static Bson includeβ(List<String> fieldNames)
fieldNames
- the field namespublic static Bson excludeβ(String... fieldNames)
fieldNames
- the field namespublic static Bson excludeβ(List<String> fieldNames)
fieldNames
- the field namespublic static Bson excludeIdβ()
public static Bson elemMatchβ(String fieldName)
fieldName
- the field name whose value is the arraypublic static Bson elemMatchβ(String fieldName, Bson filter)
fieldName
- the field namefilter
- the filter to applypublic static Bson metaTextScoreβ(String fieldName)
fieldName
- the field namepublic static Bson sliceβ(String fieldName, int limit)
fieldName
- the field namelimit
- the number of elements to project.public static Bson sliceβ(String fieldName, int skip, int limit)
fieldName
- the field nameskip
- the number of elements to skip before applying the limitlimit
- the number of elements to projectpublic static Bson fieldsβ(Bson... projections)
projections
- the list of projections to combinepublic static Bson fieldsβ(List<? extends Bson> projections)
projections
- the list of projections to combine