public final class Projections
extends java.lang.Object
collection.find().projection(fields(include("x", "y"), excludeId()))
Modifier and Type | Method and Description |
---|---|
static <TExpression> |
computed(java.lang.String fieldName,
TExpression expression)
Creates a projection of a field whose value is computed from the given expression.
|
static Bson |
elemMatch(java.lang.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(java.lang.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(java.util.List<java.lang.String> fieldNames)
Creates a projection that excludes all of the given fields.
|
static Bson |
exclude(java.lang.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(Bson... projections)
Creates a projection that combines the list of projections into a single one.
|
static Bson |
fields(java.util.List<? extends Bson> projections)
Creates a projection that combines the list of projections into a single one.
|
static Bson |
include(java.util.List<java.lang.String> fieldNames)
Creates a projection that includes all of the given fields.
|
static Bson |
include(java.lang.String... fieldNames)
Creates a projection that includes all of the given fields.
|
static Bson |
metaTextScore(java.lang.String fieldName)
Creates a projection to the given field name of the textScore, for use with text queries.
|
static Bson |
slice(java.lang.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(java.lang.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(java.lang.String fieldName, TExpression expression)
TExpression
- the expression typefieldName
- the field nameexpression
- the expressionAggregates.project(Bson)
public static Bson include(java.lang.String... fieldNames)
fieldNames
- the field namespublic static Bson include(java.util.List<java.lang.String> fieldNames)
fieldNames
- the field namespublic static Bson exclude(java.lang.String... fieldNames)
fieldNames
- the field namespublic static Bson exclude(java.util.List<java.lang.String> fieldNames)
fieldNames
- the field namespublic static Bson excludeId()
public static Bson elemMatch(java.lang.String fieldName)
fieldName
- the field name whose value is the arraypublic static Bson elemMatch(java.lang.String fieldName, Bson filter)
fieldName
- the field namefilter
- the filter to applypublic static Bson metaTextScore(java.lang.String fieldName)
fieldName
- the field namepublic static Bson slice(java.lang.String fieldName, int limit)
fieldName
- the field namelimit
- the number of elements to project.public static Bson slice(java.lang.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 combine